From 0e1e97da9e8937d19b0101dcc1f3a16e3db495b6 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sat, 6 Feb 2021 21:15:34 -0500 Subject: Added sound and animation changes to scripting --- src/script_system.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/script_system.cpp') diff --git a/src/script_system.cpp b/src/script_system.cpp index 7f4729b..e2b117a 100644 --- a/src/script_system.cpp +++ b/src/script_system.cpp @@ -2,6 +2,7 @@ #include #include "game.h" #include "message_system.h" +#include "animation_system.h" ScriptSystem::ScriptSystem(Game& game) : game_(game) { engine_.open_libraries( @@ -15,12 +16,40 @@ ScriptSystem::ScriptSystem(Game& game) : game_(game) { "hideCutsceneBars", &MessageSystem::hideCutsceneBars, "isMessageActive", sol::property(&MessageSystem::isMessageActive)); + engine_.new_usertype( + "animation", + "setSpriteAnimation", &AnimationSystem::setSpriteAnimation); + + engine_.new_usertype( + "mixer", + "playSound", &Mixer::playSound, + "loopSound", &Mixer::loopSound, + "stopChannel", &Mixer::stopChannel); + engine_.set_function( "message", [&] () -> MessageSystem& { return game_.getSystem(); }); + engine_.set_function( + "animation", + [&] () -> AnimationSystem& { + return game_.getSystem(); + }); + + engine_.set_function( + "mixer", + [&] () -> Mixer& { + return game_.getMixer(); + }); + + engine_.set_function( + "getSpriteByAlias", + [&] (std::string alias) -> int { + return game_.getSpriteByAlias(alias); + }); + engine_.script_file("../res/scripts/common.lua"); } -- cgit 1.4.1