diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2021-03-13 15:30:20 -0500 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2021-03-13 15:34:50 -0500 |
commit | 4c8e15722822d0e5e872f872838a8d71af84e1d4 (patch) | |
tree | 76ee8a4f8ee5bd24067b4d94b1a5dc2594dd5444 /src | |
parent | 02c991e5ea1ec93c8245157a3f174b547774a7e3 (diff) | |
download | tanetane-4c8e15722822d0e5e872f872838a8d71af84e1d4.tar.gz tanetane-4c8e15722822d0e5e872f872838a8d71af84e1d4.tar.bz2 tanetane-4c8e15722822d0e5e872f872838a8d71af84e1d4.zip |
Added debug info to Script object
Diffstat (limited to 'src')
-rw-r--r-- | src/script_system.cpp | 4 | ||||
-rw-r--r-- | src/script_system.h | 1 |
2 files changed, 5 insertions, 0 deletions
diff --git a/src/script_system.cpp b/src/script_system.cpp index b993938..7889148 100644 --- a/src/script_system.cpp +++ b/src/script_system.cpp | |||
@@ -286,6 +286,9 @@ void ScriptSystem::runScript(std::string mapName, std::string scriptName) { | |||
286 | Script newScript; | 286 | Script newScript; |
287 | newScript.runner.reset(new sol::thread(sol::thread::create(engine_.lua_state()))); | 287 | newScript.runner.reset(new sol::thread(sol::thread::create(engine_.lua_state()))); |
288 | newScript.callable.reset(new sol::coroutine(newScript.runner->state().traverse_get<sol::function>(mapName, scriptName))); | 288 | newScript.callable.reset(new sol::coroutine(newScript.runner->state().traverse_get<sol::function>(mapName, scriptName))); |
289 | #ifdef TANETANE_DEBUG | ||
290 | newScript.debugInfo = mapName + "." + scriptName; | ||
291 | #endif | ||
289 | 292 | ||
290 | if (!*newScript.callable) { | 293 | if (!*newScript.callable) { |
291 | throw std::runtime_error("Error running script: " + mapName + "." + scriptName); | 294 | throw std::runtime_error("Error running script: " + mapName + "." + scriptName); |
@@ -313,6 +316,7 @@ void ScriptSystem::runDebugScript(std::string script) { | |||
313 | } | 316 | } |
314 | 317 | ||
315 | newScript.callable.reset(new sol::coroutine(loaded_script)); | 318 | newScript.callable.reset(new sol::coroutine(loaded_script)); |
319 | newScript.debugInfo = script; | ||
316 | 320 | ||
317 | if (!*newScript.callable) { | 321 | if (!*newScript.callable) { |
318 | std::cout << "Error running debug command: " << script << std::endl; | 322 | std::cout << "Error running debug command: " << script << std::endl; |
diff --git a/src/script_system.h b/src/script_system.h index 7ef2dee..6a28430 100644 --- a/src/script_system.h +++ b/src/script_system.h | |||
@@ -32,6 +32,7 @@ private: | |||
32 | struct Script { | 32 | struct Script { |
33 | std::unique_ptr<sol::thread> runner; | 33 | std::unique_ptr<sol::thread> runner; |
34 | std::unique_ptr<sol::coroutine> callable; | 34 | std::unique_ptr<sol::coroutine> callable; |
35 | std::string debugInfo; | ||
35 | }; | 36 | }; |
36 | 37 | ||
37 | Game& game_; | 38 | Game& game_; |