diff options
author | Clyne Sullivan <clyne@bitgloo.com> | 2019-09-16 12:46:44 -0400 |
---|---|---|
committer | Clyne Sullivan <clyne@bitgloo.com> | 2019-09-16 12:46:44 -0400 |
commit | dbb26902ed54ce308fdcec4697616e152f2894fd (patch) | |
tree | 13f6d840e6b300c10a1f6ff54051c12d9a4126e4 /src/script.cpp | |
parent | 331e858d2dd0155b54b4bf9edfbbb84d3d5a8145 (diff) |
success with font loading
Diffstat (limited to 'src/script.cpp')
-rw-r--r-- | src/script.cpp | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/script.cpp b/src/script.cpp index a6f0968..61aa136 100644 --- a/src/script.cpp +++ b/src/script.cpp @@ -31,6 +31,9 @@ void ScriptSystem::configure([[maybe_unused]] entityx::EntityManager& entities, // Init after systems.configure() in engine.cpp //init(); + lua.open_libraries(sol::lib::base, sol::lib::math, sol::lib::string); + + scriptExport(); } #include <components/Script.hpp> @@ -54,9 +57,6 @@ void ScriptSystem::receive([[maybe_unused]] const EntitySpawnEvent &toSpawn) int ScriptSystem::init(void) { - lua.open_libraries(sol::lib::base, sol::lib::math, sol::lib::string); - - scriptExport(); doFile(); return 0; @@ -87,9 +87,6 @@ void ScriptSystem::doFile(void) void ScriptSystem::scriptExport(void) { - std::function<sol::table(sol::table)> func = - [this](sol::table t){ return spawn(t);}; - lua.new_usertype<Position>("Position", sol::constructors<Position(double x, double y), Position()>(), "x", &Position::x, @@ -124,8 +121,8 @@ void ScriptSystem::scriptExport(void) sol::constructors<Physics(void), Physics()>(), "standing", &Physics::standing); - auto gamespace = lua["game"].get_or_create<sol::table>(); - gamespace.set_function("spawn", func); + game = lua["game"].get_or_create<sol::table>(); + game.set_function("spawn", [this](sol::table t) { return spawn(t); }); } sol::table ScriptSystem::spawn(sol::object param) |