From 450cc78c9a0433a0b999a1f1fa9b2a7218e1f87c Mon Sep 17 00:00:00 2001 From: CPunch Date: Sat, 30 Dec 2023 00:56:06 -0600 Subject: [PATCH] added globalState; minor styling fixes --- src/lua/Manager.cpp | 12 ++++++++---- src/lua/Manager.hpp | 2 +- src/lua/Thread.hpp | 6 +++--- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/lua/Manager.cpp b/src/lua/Manager.cpp index af89e6d..c4968e8 100644 --- a/src/lua/Manager.cpp +++ b/src/lua/Manager.cpp @@ -2,8 +2,11 @@ #include -namespace LuaManager { - void init() { +using namespace LuaManager; + +static lua_State *globalState = nullptr; + +void init() { lua_State *L = luaL_newstate(); luaL_openlibs(L); @@ -11,5 +14,6 @@ namespace LuaManager { std::cout << "Lua error: " << lua_tostring(L, -1) << std::endl; lua_pop(L, 1); } - } -} \ No newline at end of file + + globalState = L; +} diff --git a/src/lua/Manager.hpp b/src/lua/Manager.hpp index 7608505..5e126c6 100644 --- a/src/lua/Manager.hpp +++ b/src/lua/Manager.hpp @@ -3,5 +3,5 @@ #include "lua/Thread.hpp" namespace LuaManager { - void init(); + void init(); } \ No newline at end of file diff --git a/src/lua/Thread.hpp b/src/lua/Thread.hpp index c115939..93b0329 100644 --- a/src/lua/Thread.hpp +++ b/src/lua/Thread.hpp @@ -7,8 +7,8 @@ extern "C" { } struct LuaThread { - lua_State *L; - int ref; + lua_State *L; + int ref; - LuaThread(lua_State *L, int ref) : L(L), ref(ref) {} + LuaThread(lua_State *L, int ref) : L(L), ref(ref) {} }; \ No newline at end of file