public void Update() { if (DebugEnabled) { var top = LuaBindings.lua_gettop(State); LuaBindings.lua_getglobal(State, "OnExtenderDebugUpdate"); if (LuaBindingMacros.lua_isfunction(State, -1)) { var result = LuaBindings.lua_pcallk(State, 0, 0, 0, 0, IntPtr.Zero); } else { LuaBindings.lua_settop(State, top); } } }
public void Init() { Console.WriteLine("Registered TestLog function"); lua.RegisterFunction <LuaFunc>("TestLog", TestLog); Console.WriteLine("Registered TesValue global"); lua.SetGlobal("TestValue", (double)5); if (!CustomLuaRuntime) { #pragma warning disable CS0162 // Unreachable code detected LuaHelper.OpenLibraries(State); #pragma warning restore CS0162 // Unreachable code detected } else { customRuntime.OpenLibraries(State); //Restore debug.sethook function, engine stubs it at runtime. var top = LuaBindings.lua_gettop(State); LuaBindings.lua_getglobal(State, "debug"); LuaBindings.lua_pushcclosure(State, customRuntime.db_sethook, 0); LuaBindings.lua_setfield(State, -2, "sethook"); LuaBindings.lua_settop(State, top); } if (DebugEnabled) { Console.WriteLine("Loading debug scripts"); var luadir = Path.Combine(Util.ExtenderDirectory, "lua_modules"); lua.Eval(string.Format(@"package.path = package.path .. "";{0}""", $@"{Util.ExtenderDirectory}\?.lua".Replace(@"\", @"\\"))); lua.Eval(string.Format(@"package.path = package.path .. "";{0}""", $@"{luadir}\share\lua\5.2\?.lua".Replace(@"\", @"\\"))); lua.Eval(string.Format(@"package.cpath = package.cpath .. "";{0}""", $@"{luadir}\lib\lua\5.2\?.dll".Replace(@"\", @"\\"))); if (File.Exists($"{Util.ExtenderDirectory}/InitDebugging.lua")) { lua.LoadFile($"{Util.ExtenderDirectory}/InitDebugging.lua"); } } RegisterLoadBanks(); }