public ThreadStatus PCall(int numArgs, int numResults, int errFunc) { LuaState lua = LuaInstance.Instance.Get(); int errorHandlerIndex = 0; #if UNITY_EDITOR || UNITY_STANDALONE lua.GetGlobal("lua_get_debug_info"); lua.PushValue(-2 - numArgs); for (int i = 0; i < numArgs; i++) { lua.PushValue(-numArgs - 2); } errorHandlerIndex = -2 - numArgs; #endif if (LuaAPI.lua_pcall(this.luaPtr, numArgs, numResults, errorHandlerIndex) != 0) { DebugLogger.LogError("lua Error stack: " + LuaInstance.ConstructString(lua)); #if UNITY_EDITOR || UNITY_STANDALONE lua.Pop(numArgs + 3); #endif return(ThreadStatus.LUA_ERRRUN); } #if UNITY_EDITOR || UNITY_STANDALONE int removeNum = numArgs + 2; while (removeNum > 0) { lua.Remove(-numResults - 1); removeNum--; } #endif return(ThreadStatus.LUA_OK); }
public string ErrorInfo() { LuaAPI.lua_geterror_info(this.luaPtr); if (this.IsNil(-1)) { return(string.Empty); } string errorInfo = LuaInstance.ConstructString(LuaInstance.Instance.Get()); return(errorInfo); }
public ThreadStatus L_DoFile(string filename) { #if LUAPACK if ((LuaAPI.luaL_loadpak(this.m_lua, filename) == 0) && (LuaAPI.lua_pcall(this.m_lua, 0, -1, 0) == 0)) { return(ThreadStatus.LUA_OK); } #else if ((LuaAPI.luaL_loadfile(this.luaPtr, filename) == 0) && (LuaAPI.lua_pcall(this.luaPtr, 0, -1, 0) == 0)) { return(ThreadStatus.LUA_OK); } #endif DebugLogger.LogError("DoFile Error: " + filename + "\nlua stack: " + LuaInstance.ConstructString(LuaInstance.Instance.Get())); return(ThreadStatus.LUA_ERRRUN); }