public static void DoString(IntPtr L, string script)
        {
            LuaHook.isHook = false;
            byte[] chunk  = Encoding.UTF8.GetBytes(script);
            int    oldTop = LuaDLL.lua_gettop(L);

#if XLUA
            int errFunc = LuaDLL.load_error_func(L, -1);

            if (LuaLib.luaL_loadbuffer(L, chunk, chunk.Length, "chunk") == 0)
            {
                if (LuaDLL.lua_pcall(L, 0, -1, errFunc) == 0)
                {
                    LuaDLL.lua_remove(L, errFunc);
                }
            }
            else
            {
                Debug.Log(script);
            }
#elif TOLUA
            if (LuaLib.luaL_loadbuffer(L, chunk, chunk.Length, "chunk") == 0)
            {
                LuaDLL.lua_call(L, 0, -1);
            }
#elif SLUA
            if (LuaLib.luaL_loadbuffer(L, chunk, chunk.Length, "chunk") == 0)
            {
                LuaDLL.lua_call(L, 0, -1);
            }
#endif
            LuaHook.isHook = true;
            LuaDLL.lua_settop(L, oldTop);
        }
Ejemplo n.º 2
0
        public static void DoString(IntPtr L, string script)
        {
            LuaHook.isHook = false;
            byte[] chunk  = Encoding.UTF8.GetBytes(script);
            int    oldTop = LuaDLL.lua_gettop(L);

            lua_getglobal(L, "miku_handle_error");
            if (LuaLib.luaL_loadbuffer(L, chunk, chunk.Length, "chunk") == 0)
            {
                if (LuaDLL.lua_pcall(L, 0, -1, oldTop + 1) == 0)
                {
                    LuaDLL.lua_remove(L, oldTop + 1);
                }
            }
            else
            {
                Debug.Log(script);
            }
            LuaHook.isHook = true;
            LuaDLL.lua_settop(L, oldTop);
        }