diff options
| author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2018-05-10 19:42:41 -0400 |
|---|---|---|
| committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2018-05-17 15:39:39 -0400 |
| commit | cfb2bee13b595bd5304b97f846db8b359010b515 (patch) | |
| tree | 7e0851fdac7241a78ea5fec7daefdebc1a26ae1a /src/systems | |
| parent | 4bbfeae42a1245b1b84e8847787d7643e6a6f2cf (diff) | |
| download | therapy-cfb2bee13b595bd5304b97f846db8b359010b515.tar.gz therapy-cfb2bee13b595bd5304b97f846db8b359010b515.tar.bz2 therapy-cfb2bee13b595bd5304b97f846db8b359010b515.zip | |
Added error checking to AutomatingSystem
Diffstat (limited to 'src/systems')
| -rw-r--r-- | src/systems/automating.cpp | 15 |
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 | ||
| 52 | void AutomatingSystem::initScriptEngine(sol::state& scriptEngine) | 63 | void AutomatingSystem::initScriptEngine(sol::state& scriptEngine) |
