/* * Excutes a Lua file and returns all the chunk's return * values in an array */ public object[] DoFile(string fileName) { int oldTop = LuaLib.LuaGetTop(luaState); if (LuaLib.LuaLLoadFile(luaState, fileName) == 0) { executing = true; try { if (LuaLib.LuaPCall(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> /// Load a File on, and return a LuaFunction to execute the file loaded (useful to see if the syntax of a file is ok) /// </summary> /// <param name = "fileName"></param> /// <returns></returns> public LuaFunction LoadFile(string fileName) { int oldTop = LuaLib.LuaGetTop(luaState); if (LuaLib.LuaLLoadFile(luaState, fileName) != 0) { ThrowExceptionFromError(oldTop); } var result = translator.GetFunction(luaState, -1); translator.PopValues(luaState, oldTop); return(result); }