From dbb26902ed54ce308fdcec4697616e152f2894fd Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Mon, 16 Sep 2019 12:46:44 -0400 Subject: success with font loading --- src/script.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'src/script.cpp') 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 @@ -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 func = - [this](sol::table t){ return spawn(t);}; - lua.new_usertype("Position", sol::constructors(), "x", &Position::x, @@ -124,8 +121,8 @@ void ScriptSystem::scriptExport(void) sol::constructors(), "standing", &Physics::standing); - auto gamespace = lua["game"].get_or_create(); - gamespace.set_function("spawn", func); + game = lua["game"].get_or_create(); + game.set_function("spawn", [this](sol::table t) { return spawn(t); }); } sol::table ScriptSystem::spawn(sol::object param) -- cgit v1.2.3