added globalState; minor styling fixes

This commit is contained in:
CPunch 2023-12-30 00:56:06 -06:00
parent 95f2920f5c
commit 450cc78c9a
3 changed files with 12 additions and 8 deletions

View File

@ -2,8 +2,11 @@
#include <iostream> #include <iostream>
namespace LuaManager { using namespace LuaManager;
void init() {
static lua_State *globalState = nullptr;
void init() {
lua_State *L = luaL_newstate(); lua_State *L = luaL_newstate();
luaL_openlibs(L); luaL_openlibs(L);
@ -11,5 +14,6 @@ namespace LuaManager {
std::cout << "Lua error: " << lua_tostring(L, -1) << std::endl; std::cout << "Lua error: " << lua_tostring(L, -1) << std::endl;
lua_pop(L, 1); lua_pop(L, 1);
} }
}
globalState = L;
} }

View File

@ -3,5 +3,5 @@
#include "lua/Thread.hpp" #include "lua/Thread.hpp"
namespace LuaManager { namespace LuaManager {
void init(); void init();
} }

View File

@ -7,8 +7,8 @@ extern "C" {
} }
struct LuaThread { struct LuaThread {
lua_State *L; lua_State *L;
int ref; int ref;
LuaThread(lua_State *L, int ref) : L(L), ref(ref) {} LuaThread(lua_State *L, int ref) : L(L), ref(ref) {}
}; };