public ScriptManager(SymbolResolver resolver, bool enableDebug) { DebugEnabled = enableDebug; Console.WriteLine("Initializing ScriptManager"); Resolver = resolver; luaInterface = resolver.Resolve <LuaInterface>("?LUA_INTERFACE@ScriptManager@sgg@@2ULua@@A"); enableMessageHook = resolver.Resolve <bool>("?EnableLuaMessageHook@ConfigOptions@sgg@@2_NA"); l_msghandler = resolver.Resolve("l_msghandler"); l_panic = resolver.Resolve("l_panic"); lua = new Lua(resolver, luaInterface); if (CustomLuaRuntime) { customRuntime = new CustomLuaRuntimeManager(); customRuntime.Init(resolver, luaInterface, l_msghandler, l_panic, enableMessageHook); } }
private unsafe void OpenLua(LuaInterface *luaInterface, IntPtr l_msghandler, IntPtr l_panic, bool *enableMessageHook) { Console.WriteLine($"Opening lua. Message hooks enabled={*enableMessageHook}"); luaInterface->state = CustomLuaRuntimeManager.luaL_newstate(); luaInterface->destroyed = false; if (!*enableMessageHook) { LuaBindings.luaL_openlibs(luaInterface->state); } else { LuaBindings.lua_pushcclosure(luaInterface->state, l_msghandler, 0); var top = LuaBindings.lua_gettop(luaInterface->state); luaInterface->msghander = top; LuaBindings.lua_atpanic(luaInterface->state, l_panic); LuaBindings.luaL_openlibs(luaInterface->state); LuaBindings.luaopen_debug(luaInterface->state); } }