diff options
Diffstat (limited to 'src/engine/script.hpp')
| -rw-r--r-- | src/engine/script.hpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/engine/script.hpp b/src/engine/script.hpp new file mode 100644 index 0000000..8008ded --- /dev/null +++ b/src/engine/script.hpp @@ -0,0 +1,21 @@ +#pragma once + +#include <sol/sol.hpp> +#include <string> + +// Thin wrapper around a sol2 Lua state. This is the engine's scripting seam: +// data files (materials, later weapons/devices) are Lua, loaded on top of each +// other so mods can extend or override the base tables. +class ScriptEngine { +public: + ScriptEngine(); + + sol::state& lua() { return lua_; } + + // Run a Lua file in the shared state. Returns false and logs on error + // (errors are caught, never thrown out, so a bad mod can't crash the game). + bool run_file(const std::string& path); + +private: + sol::state lua_; +}; |
