diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/script_system.cpp | 26 |
1 files changed, 25 insertions, 1 deletions
| diff --git a/src/script_system.cpp b/src/script_system.cpp index a5e9403..6b35b73 100644 --- a/src/script_system.cpp +++ b/src/script_system.cpp | |||
| @@ -10,6 +10,11 @@ ScriptSystem::ScriptSystem(Game& game) : game_(game) { | |||
| 10 | sol::lib::coroutine, | 10 | sol::lib::coroutine, |
| 11 | sol::lib::math); | 11 | sol::lib::math); |
| 12 | 12 | ||
| 13 | engine_.new_usertype<Sprite>( | ||
| 14 | "sprite", | ||
| 15 | "dir", &Sprite::dir, | ||
| 16 | "followers", &Sprite::followers); | ||
| 17 | |||
| 13 | engine_.new_usertype<MessageSystem>( | 18 | engine_.new_usertype<MessageSystem>( |
| 14 | "message", | 19 | "message", |
| 15 | "displayMessage", &MessageSystem::displayMessage, | 20 | "displayMessage", &MessageSystem::displayMessage, |
| @@ -18,7 +23,8 @@ ScriptSystem::ScriptSystem(Game& game) : game_(game) { | |||
| 18 | 23 | ||
| 19 | engine_.new_usertype<AnimationSystem>( | 24 | engine_.new_usertype<AnimationSystem>( |
| 20 | "animation", | 25 | "animation", |
| 21 | "setSpriteAnimation", &AnimationSystem::setSpriteAnimation); | 26 | "setSpriteAnimation", &AnimationSystem::setSpriteAnimation, |
| 27 | "setSpriteDirection", &AnimationSystem::setSpriteDirection); | ||
| 22 | 28 | ||
| 23 | engine_.new_usertype<Mixer>( | 29 | engine_.new_usertype<Mixer>( |
| 24 | "mixer", | 30 | "mixer", |
| @@ -51,6 +57,24 @@ ScriptSystem::ScriptSystem(Game& game) : game_(game) { | |||
| 51 | }); | 57 | }); |
| 52 | 58 | ||
| 53 | engine_.set_function( | 59 | engine_.set_function( |
| 60 | "getControllableSprite", | ||
| 61 | [&] () -> int { | ||
| 62 | for (int id : game_.getSprites()) { | ||
| 63 | Sprite& sprite = game_.getSprite(id); | ||
| 64 | if (sprite.controllable) { | ||
| 65 | return id; | ||
| 66 | } | ||
| 67 | } | ||
| 68 | return -1; | ||
| 69 | }); | ||
| 70 | |||
| 71 | engine_.set_function( | ||
| 72 | "getSprite", | ||
| 73 | [&] (int id) -> Sprite& { | ||
| 74 | return game_.getSprite(id); | ||
| 75 | }); | ||
| 76 | |||
| 77 | engine_.set_function( | ||
| 54 | "loadMap", | 78 | "loadMap", |
| 55 | [&] (std::string filename, std::string warpPoint) { | 79 | [&] (std::string filename, std::string warpPoint) { |
| 56 | game_.loadMap(filename, warpPoint); | 80 | game_.loadMap(filename, warpPoint); |
