Ejemplo n.º 1
0
        internal static int print(IntPtr L)
        {
            int    num  = LuaDLL.pua_gettop(L);
            string text = string.Empty;

            LuaDLL.pua_getglobal(L, "tostring");
            for (int i = 1; i <= num; i++)
            {
                if (i > 1)
                {
                    text += "    ";
                }
                LuaDLL.pua_pushvalue(L, -1);
                LuaDLL.pua_pushvalue(L, i);
                LuaDLL.pua_call(L, 1, 1);
                text += LuaDLL.pua_tostring(L, -1);
                LuaDLL.pua_pop(L, 1);
            }
            LuaDLL.pua_settop(L, num);
            SLogger.Log(text);
            if (LuaState.logDelegate != null)
            {
                LuaState.logDelegate(text);
            }
            return(0);
        }
Ejemplo n.º 2
0
        internal static int print(IntPtr L)
        {
            int    n = LuaDLL.pua_gettop(L);
            string s = "";

            LuaDLL.pua_getglobal(L, "tostring");

            for (int i = 1; i <= n; i++)
            {
                if (i > 1)
                {
                    s += "    ";
                }

                LuaDLL.pua_pushvalue(L, -1);
                LuaDLL.pua_pushvalue(L, i);

                LuaDLL.pua_call(L, 1, 1);
                s += LuaDLL.pua_tostring(L, -1);
                LuaDLL.pua_pop(L, 1);
            }
            LuaDLL.pua_settop(L, n);
            SLogger.Log(s);
            if (logDelegate != null)
            {
                logDelegate(s);
            }
            return(0);
        }
Ejemplo n.º 3
0
 public void Close()
 {
     if (this.L != IntPtr.Zero && LuaState.main == this)
     {
         SLogger.Log("Finalizing Lua State.");
         LuaDLL.pua_close(this.L);
         ObjectCache.del(this.L);
         ObjectCache.clear();
         LuaState.statemap.Clear();
         LuaState.oldptr   = IntPtr.Zero;
         LuaState.oldstate = null;
         this.L            = IntPtr.Zero;
         LuaState.main     = null;
     }
 }
Ejemplo n.º 4
0
        public void Close()
        {
            if (L != IntPtr.Zero)
            {
                if (LuaState.main == this)
                {
                    SLogger.Log("Finalizing Lua State.");
                    // be careful, if you close lua vm, make sure you don't use lua state again,
                    // comment this line as default for avoid unexpected crash.
                    LuaDLL.pua_close(L);

                    ObjectCache.del(L);
                    ObjectCache.clear();

                    statemap.Clear();
                    oldptr   = IntPtr.Zero;
                    oldstate = null;
                    L        = IntPtr.Zero;

                    LuaState.main = null;
                }
            }
        }