diff --git a/src/sdfml/sdfml_lua.cpp b/src/sdfml/sdfml_lua.cpp index 816e19a..4e2b36c 100644 --- a/src/sdfml/sdfml_lua.cpp +++ b/src/sdfml/sdfml_lua.cpp @@ -1,19 +1,6 @@ #include "sdfml_lua.hpp" -int sdfml::LuaHandler::create_from_lua_state(lua_State *L, std::string path, bool immediate) { - _prefer_view = true; - sol::state_view temp(L); - _lua_view = temp; - _cur_result = _lua_view.load_file(path.c_str()); - if (immediate) - return 0; - - sol::protected_function_result result = _cur_result(); - return 1 - result.valid(); -} - int sdfml::LuaHandler::open_state(std::string path, bool immediate) { - _prefer_view = false; _cur_result = _lua_state.load_file(path.c_str()); if (immediate) return 0; @@ -29,18 +16,15 @@ int sdfml::LuaHandler::run_state() { template void sdfml::LuaHandler::set_variable(std::string var_name, TName value) { - if (_prefer_view) _lua_view[var_name] = value; return; _lua_state[var_name] = value; } template TName sdfml::LuaHandler::get_variable(std::string var_name) { - if (_prefer_view) return _lua_state.get(var_name); return _lua_state.get(var_name); } template void sdfml::LuaHandler::add_libraries(Args&&... libraries) { - if (_prefer_view) _lua_view.open_libraries(libraries...); return; _lua_state.open_libraries(libraries...); } \ No newline at end of file diff --git a/src/sdfml/sdfml_lua.hpp b/src/sdfml/sdfml_lua.hpp index fcb7fcb..d55a094 100644 --- a/src/sdfml/sdfml_lua.hpp +++ b/src/sdfml/sdfml_lua.hpp @@ -12,14 +12,11 @@ namespace sdfml { class LuaHandler { protected: sol::state _lua_state; - sol::state_view _lua_view = NULL; sol::load_result _cur_result; bool _prefer_view = false; public: int open_state(std::string path, bool immediate = false); - int create_from_lua_state(lua_State* L, std::string path, bool immediate = false); - int run_state(); template @@ -32,7 +29,7 @@ namespace sdfml { void add_libraries(Args&&... libraries); }; - //static LuaHandler lua; + static LuaHandler lua; } #endif \ No newline at end of file