コード例 #1
0
ファイル: LuaStatic.cs プロジェクト: TonyDongGuaPi/joework
        public static int print(IntPtr L)
        {
            int    num  = LuaDLL.lua_gettop(L);
            string text = string.Empty;

            LuaDLL.lua_getglobal(L, "tostring");
            for (int i = 1; i <= num; i++)
            {
                LuaDLL.lua_pushvalue(L, -1);
                LuaDLL.lua_pushvalue(L, i);
                LuaDLL.lua_call(L, 1, 1);
                if (i > 1)
                {
                    text += "\t";
                }
                text += LuaDLL.lua_tostring(L, -1);
                LuaDLL.lua_pop(L, 1);
            }
            LuaStatic.LuaLog("LUA: " + text);
            return(0);
        }
コード例 #2
0
ファイル: LuaState.cs プロジェクト: isoundy000/wzry-1
        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);
        }
コード例 #3
0
ファイル: LuaStatic.cs プロジェクト: TonyDongGuaPi/joework
        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);
        }
コード例 #4
0
ファイル: LuaState.cs プロジェクト: TonyDongGuaPi/joework
        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);
        }
コード例 #5
0
ファイル: LuaStatic.cs プロジェクト: TonyDongGuaPi/joework
 public static int loadfile(IntPtr L)
 {
     return(LuaStatic.loader(L));
 }