summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--src/systems/automating.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/systems/automating.cpp b/src/systems/automating.cpp index 6cec3bf..5233e3e 100644 --- a/src/systems/automating.cpp +++ b/src/systems/automating.cpp
@@ -31,7 +31,12 @@ void AutomatingSystem::tick(double dt)
31 continue; 31 continue;
32 } 32 }
33 33
34 (*automatable.behavior)(dt); 34 auto result = (*automatable.behavior)(dt);
35 if (!result.valid())
36 {
37 sol::error e = result;
38 throw std::runtime_error(e.what());
39 }
35 } 40 }
36} 41}
37 42
@@ -46,7 +51,13 @@ void AutomatingSystem::initPrototype(id_type prototype)
46 automatable.behavior.reset(); 51 automatable.behavior.reset();
47 automatable.runner = std::unique_ptr<sol::thread>(new sol::thread(sol::thread::create(realizable.scriptEngine.lua_state()))); 52 automatable.runner = std::unique_ptr<sol::thread>(new sol::thread(sol::thread::create(realizable.scriptEngine.lua_state())));
48 automatable.behavior = std::unique_ptr<sol::coroutine>(new sol::coroutine(automatable.runner->state()["run"])); 53 automatable.behavior = std::unique_ptr<sol::coroutine>(new sol::coroutine(automatable.runner->state()["run"]));
49 (*automatable.behavior)(script_entity(prototype)); 54
55 auto result = (*automatable.behavior)(script_entity(prototype));
56 if (!result.valid())
57 {
58 sol::error e = result;
59 throw std::runtime_error(e.what());
60 }
50} 61}
51 62
52void AutomatingSystem::initScriptEngine(sol::state& scriptEngine) 63void AutomatingSystem::initScriptEngine(sol::state& scriptEngine)