Ejemplo n.º 1
0
        public static int dofile(IntPtr L)
        {
            string text = string.Empty;

            text = LuaDLL.lua_tostring(L, 1);
            string text2 = text.ToLower();

            if (text2.EndsWith(".lua"))
            {
                int num = text.LastIndexOf('.');
                text = text.Substring(0, num);
            }
            text = text.Replace('.', '/') + ".lua";
            int num2 = LuaDLL.lua_gettop(L);

            byte[] array = LuaStatic.Load(text);
            if (array == null)
            {
                return(LuaDLL.lua_gettop(L) - num2);
            }
            if (LuaDLL.luaL_loadbuffer(L, array, array.Length, text) == 0)
            {
                LuaDLL.lua_call(L, 0, LuaDLL.LUA_MULTRET);
            }
            return(LuaDLL.lua_gettop(L) - num2);
        }
Ejemplo n.º 2
0
        public object[] DoFile(string fileName, LuaTable env)
        {
            LuaDLL.lua_pushstdcallcfunction(this.L, this.tracebackFunction, 0);
            int oldTop = LuaDLL.lua_gettop(this.L);

            byte[] buff = LuaStatic.Load(fileName);
            if (buff == null)
            {
                if (!fileName.Contains("mobdebug"))
                {
                }
                LuaDLL.lua_pop(this.L, 1);
                return(null);
            }
            string name = Util.LuaPath(fileName);

            if (LuaDLL.luaL_loadbuffer(this.L, buff, buff.Length, name) == 0)
            {
                if (env != null)
                {
                    env.push(this.L);
                    LuaDLL.lua_setfenv(this.L, -2);
                }
                if (LuaDLL.lua_pcall(this.L, 0, -1, -2) == 0)
                {
                    object[] objArray = this.translator.popValues(this.L, oldTop);
                    LuaDLL.lua_pop(this.L, 1);
                    return(objArray);
                }
                this.ThrowExceptionFromError(oldTop);
                LuaDLL.lua_pop(this.L, 1);
            }
            else
            {
                this.ThrowExceptionFromError(oldTop);
                LuaDLL.lua_pop(this.L, 1);
            }
            return(null);
        }
Ejemplo n.º 3
0
        public static int loader(IntPtr L)
        {
            string text = string.Empty;

            text = LuaDLL.lua_tostring(L, 1);
            string text2 = text.ToLower();

            if (text2.EndsWith(".lua"))
            {
                int num = text.LastIndexOf('.');
                text = text.Substring(0, num);
            }
            text = text.Replace('.', '/') + ".lua";
            LuaScriptMgr mgrFromLuaState = LuaScriptMgr.GetMgrFromLuaState(L);

            if (mgrFromLuaState == null)
            {
                return(0);
            }
            LuaDLL.lua_pushstdcallcfunction(L, mgrFromLuaState.lua.tracebackFunction, 0);
            int oldTop = LuaDLL.lua_gettop(L);

            byte[] array = LuaStatic.Load(text);
            if (array == null)
            {
                if (!text.Contains("mobdebug"))
                {
                    Debug.LogError("Loader lua file failed: " + text);
                }
                LuaDLL.lua_pop(L, 1);
                return(0);
            }
            if (LuaDLL.luaL_loadbuffer(L, array, array.Length, text) != 0)
            {
                mgrFromLuaState.lua.ThrowExceptionFromError(oldTop);
                LuaDLL.lua_pop(L, 1);
            }
            return(1);
        }
Ejemplo n.º 4
0
        public object[] DoFile(string fileName, LuaTable env)
        {
            LuaDLL.lua_pushstdcallcfunction(this.L, this.tracebackFunction, 0);
            int oldTop = LuaDLL.lua_gettop(this.L);

            byte[] array = LuaStatic.Load(fileName);
            if (array == null)
            {
                if (!fileName.Contains("mobdebug"))
                {
                    Debug.LogError("Loader lua file failed: " + fileName);
                }
                LuaDLL.lua_pop(this.L, 1);
                return(null);
            }
            if (LuaDLL.luaL_loadbuffer(this.L, array, array.Length, fileName) == 0)
            {
                if (env != null)
                {
                    env.push(this.L);
                    LuaDLL.lua_setfenv(this.L, -2);
                }
                if (LuaDLL.lua_pcall(this.L, 0, -1, -2) == 0)
                {
                    object[] result = this.translator.popValues(this.L, oldTop);
                    LuaDLL.lua_pop(this.L, 1);
                    return(result);
                }
                this.ThrowExceptionFromError(oldTop);
                LuaDLL.lua_pop(this.L, 1);
            }
            else
            {
                this.ThrowExceptionFromError(oldTop);
                LuaDLL.lua_pop(this.L, 1);
            }
            return(null);
        }