diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2021-02-12 00:33:19 -0500 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2021-02-12 00:33:19 -0500 |
commit | 5ecd0f428dd8292a17c5013c525a4f5d3967acb8 (patch) | |
tree | 0068b66a1183f822909f115a142fae3869a3b09f /src/script_system.cpp | |
parent | 19be2ac58b09c5240a32e6a4f41cd9f6cda03d07 (diff) | |
download | tanetane-5ecd0f428dd8292a17c5013c525a4f5d3967acb8.tar.gz tanetane-5ecd0f428dd8292a17c5013c525a4f5d3967acb8.tar.bz2 tanetane-5ecd0f428dd8292a17c5013c525a4f5d3967acb8.zip |
Scripts are organised per-map now
Diffstat (limited to 'src/script_system.cpp')
-rw-r--r-- | src/script_system.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/script_system.cpp b/src/script_system.cpp index 21d4090..5b9b987 100644 --- a/src/script_system.cpp +++ b/src/script_system.cpp | |||
@@ -120,17 +120,17 @@ void ScriptSystem::tick(double dt) { | |||
120 | } | 120 | } |
121 | } | 121 | } |
122 | 122 | ||
123 | void ScriptSystem::runScript(std::string name) { | 123 | void ScriptSystem::runScript(std::string mapName, std::string scriptName) { |
124 | if (!loadedScripts_.count(name)) { | 124 | if (!loadedScripts_.count(mapName)) { |
125 | engine_.script_file("../res/scripts/" + name + ".lua"); | 125 | engine_.script_file("../res/scripts/" + mapName + ".lua"); |
126 | loadedScripts_.insert(name); | 126 | loadedScripts_.insert(mapName); |
127 | } | 127 | } |
128 | 128 | ||
129 | runner_.reset(new sol::thread(sol::thread::create(engine_.lua_state()))); | 129 | runner_.reset(new sol::thread(sol::thread::create(engine_.lua_state()))); |
130 | callable_.reset(new sol::coroutine(runner_->state().get<sol::function>(name))); | 130 | callable_.reset(new sol::coroutine(runner_->state().traverse_get<sol::function>(mapName, scriptName))); |
131 | 131 | ||
132 | if (!*callable_) { | 132 | if (!*callable_) { |
133 | throw std::runtime_error("Error running script: " + name); | 133 | throw std::runtime_error("Error running script: " + mapName + "." + scriptName); |
134 | } | 134 | } |
135 | 135 | ||
136 | auto result = (*callable_)(); | 136 | auto result = (*callable_)(); |