/* * Excutes a Lua file and returns all the chunk's return * values in an array */ public object[] DoFile(string fileName) { int oldTop = LuaLib.lua_gettop(luaState); if (LuaLib.luaL_loadfile(luaState, fileName) == 0) { executing = true; try { if (LuaLib.lua_pcall(luaState, 0, -1, 0) == 0) { return(translator.popValues(luaState, oldTop)); } else { ThrowExceptionFromError(oldTop); } } finally { executing = false; } } else { ThrowExceptionFromError(oldTop); } return(null); // Never reached - keeps compiler happy }
/// <summary> /// /// </summary> /// <param name = "fileName"></param> /// <returns></returns> public LuaFunction LoadFile(string fileName) { int oldTop = LuaLib.lua_gettop(luaState); if (LuaLib.luaL_loadfile(luaState, fileName) != 0) { ThrowExceptionFromError(oldTop); } var result = translator.getFunction(luaState, -1); translator.popValues(luaState, oldTop); return(result); }