Example #1
0
        /*
         * Excutes a Lua file and returns all the chunk's return
         * values in an array
         */
        public object[] DoFile(string fileName)
        {
            int oldTop = LuaDLL.lua_gettop(luaState);

            if (LuaDLL.luaL_loadfile(luaState, fileName) == 0)
            {
                executing = true;
                try
                {
                    if (LuaDLL.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
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="fileName"></param>
        /// <returns></returns>
        public LuaFunction LoadFile(string fileName)
        {
            int oldTop = LuaDLL.lua_gettop(luaState);

            if (LuaDLL.luaL_loadfile(luaState, fileName) != 0)
            {
                ThrowExceptionFromError(oldTop);
            }

            LuaFunction result = translator.getFunction(luaState, -1);

            translator.popValues(luaState, oldTop);

            return(result);
        }