//returns false if game was busy
        public bool SaveLoadedFiles()
        {
            bool wasRunning = this.DebugEngine.CurrentState == DebugState.Running;

            if (wasRunning)
            {
                if (!GameLoopHook.PauseGame())
                {
                    return(false);
                }
            }

            string data = CreateFileString();

            BBLua.lua_newtable(this.L);
            int i = 1;

            foreach (string substr in data.SplitBy(15000)) //the limit in shok seems to be at ~ 2^14, otherwise crashes savegame loading
            {
                BBLua.lua_pushstring(this.L, substr);
                BBLua.lua_rawseti(this.L, -2, i);
                i++;
            }
            BBLua.lua_setglobal(this.L, "_LuaDebugger_FileData");

            if (wasRunning)
            {
                GameLoopHook.ResumeGame();
            }

            return(true);
        }
Beispiel #2
0
 protected void RegisterLogFunction()
 {
     BBLua.lua_pushstring(this.ls.L, "LuaDebugger");
     BBLua.lua_newtable(this.ls.L);
     BBLua.lua_pushstring(this.ls.L, "Log");
     BBLua.lua_pushcclosure(this.ls.L, Marshal.GetFunctionPointerForDelegate(this.logCallback), 0);
     BBLua.lua_rawset(this.ls.L, -3);
     BBLua.lua_rawset(this.ls.L, (int)LuaPseudoIndices.GLOBALSINDEX);
 }
Beispiel #3
0
 public static void lua_setglobal(UIntPtr L, string name)
 {
     BBLua.lua_pushstring(L, name);
     BBLua.lua_insert(L, -2);
     BBLua.lua_rawset(L, (int)LuaPseudoIndices.GLOBALSINDEX);
 }