summary refs log tree commit diff stats
path: root/src/script_system.h
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2021-02-21 23:46:37 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2021-02-21 23:46:37 -0500
commit9890cbf428b6216b05de02805c77c45d7b0983ab (patch)
tree71a26396e28dac90d64d13ae613e3e10cc7fdaab /src/script_system.h
parent36c784589714f4056eeeba7747e7c20a09333b70 (diff)
downloadtanetane-9890cbf428b6216b05de02805c77c45d7b0983ab.tar.gz
tanetane-9890cbf428b6216b05de02805c77c45d7b0983ab.tar.bz2
tanetane-9890cbf428b6216b05de02805c77c45d7b0983ab.zip
Multiple scripts can be run at once
And they're all on their own threads again. This is mostly so debug commands can be run during execution of other scripts. But it can also be useful for map init scripts (if we want a script to run whenever a map is loaded, even though map loading is usually done by a script).
Diffstat (limited to 'src/script_system.h')
-rw-r--r--src/script_system.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/script_system.h b/src/script_system.h index 2d099e3..18850b3 100644 --- a/src/script_system.h +++ b/src/script_system.h
@@ -4,6 +4,7 @@
4#include <sol/sol.hpp> 4#include <sol/sol.hpp>
5#include <memory> 5#include <memory>
6#include <set> 6#include <set>
7#include <list>
7#include <string> 8#include <string>
8#include "system.h" 9#include "system.h"
9 10
@@ -24,9 +25,14 @@ public:
24 25
25private: 26private:
26 27
28 struct Script {
29 std::unique_ptr<sol::thread> runner;
30 std::unique_ptr<sol::coroutine> callable;
31 };
32
27 Game& game_; 33 Game& game_;
28 sol::state engine_; 34 sol::state engine_;
29 std::unique_ptr<sol::coroutine> callable_; 35 std::list<Script> scripts_;
30 std::set<std::string> loadedScripts_; 36 std::set<std::string> loadedScripts_;
31}; 37};
32 38