diff options
Diffstat (limited to 'src/script_system.cpp')
-rw-r--r-- | src/script_system.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/script_system.cpp b/src/script_system.cpp index b4a7b9b..c820ecb 100644 --- a/src/script_system.cpp +++ b/src/script_system.cpp | |||
@@ -269,6 +269,12 @@ void ScriptSystem::tick(double dt) { | |||
269 | }); | 269 | }); |
270 | } | 270 | } |
271 | 271 | ||
272 | void ScriptSystem::destroySprite(int spriteId) { | ||
273 | scripts_.remove_if([spriteId] (const Script& script) { | ||
274 | return (script.linkedSprite == spriteId); | ||
275 | }); | ||
276 | } | ||
277 | |||
272 | void ScriptSystem::loadMapScripts(std::string mapName) { | 278 | void ScriptSystem::loadMapScripts(std::string mapName) { |
273 | if (!loadedScripts_.count(mapName)) { | 279 | if (!loadedScripts_.count(mapName)) { |
274 | engine_.script_file("../res/scripts/" + mapName + ".lua"); | 280 | engine_.script_file("../res/scripts/" + mapName + ".lua"); |
@@ -282,7 +288,7 @@ bool ScriptSystem::mapHasScript(std::string mapName, std::string scriptName) { | |||
282 | return !!engine_.traverse_get<sol::function>(mapName, scriptName); | 288 | return !!engine_.traverse_get<sol::function>(mapName, scriptName); |
283 | } | 289 | } |
284 | 290 | ||
285 | void ScriptSystem::runScript(std::string mapName, std::string scriptName) { | 291 | void ScriptSystem::runScript(std::string mapName, std::string scriptName, int linkedSprite) { |
286 | loadMapScripts(mapName); | 292 | loadMapScripts(mapName); |
287 | 293 | ||
288 | Script newScript; | 294 | Script newScript; |
@@ -291,6 +297,7 @@ void ScriptSystem::runScript(std::string mapName, std::string scriptName) { | |||
291 | #ifdef TANETANE_DEBUG | 297 | #ifdef TANETANE_DEBUG |
292 | newScript.debugInfo = mapName + "." + scriptName; | 298 | newScript.debugInfo = mapName + "." + scriptName; |
293 | #endif | 299 | #endif |
300 | newScript.linkedSprite = linkedSprite; | ||
294 | 301 | ||
295 | if (!*newScript.callable) { | 302 | if (!*newScript.callable) { |
296 | throw std::runtime_error("Error running script: " + mapName + "." + scriptName); | 303 | throw std::runtime_error("Error running script: " + mapName + "." + scriptName); |