LuaInterface.LuaDLL.lua_setfenv C# (CSharp) Method

lua_setfenv() private method

private lua_setfenv ( IntPtr luaState, int stackPos ) : int
luaState System.IntPtr
stackPos int
return int
        public static extern int lua_setfenv(IntPtr luaState, int stackPos);

Usage Example

示例#1
0
        /// <summary>
        /// Executes a Lua chnk and returns all the chunk's return values in an array.
        /// </summary>
        /// <param name="chunk">Chunk to execute</param>
        /// <param name="chunkName">Name to associate with the chunk</param>
        /// <returns></returns>
        public object[] DoString(string chunk, string chunkName, LuaTable env)
        {
            int oldTop = LuaDLL.lua_gettop(L);

            byte[] bt = Encoding.UTF8.GetBytes(chunk);

            if (LuaDLL.luaL_loadbuffer(L, bt, bt.Length, chunkName) == 0)
            {
                if (env != null)
                {
                    env.push(L);
                    //LuaDLL.lua_setfenv(L, -1);
                    LuaDLL.lua_setfenv(L, -2);
                }

                if (LuaDLL.lua_pcall(L, 0, -1, 0) == 0)
                {
                    return(translator.popValues(L, oldTop));
                }
                else
                {
                    ThrowExceptionFromError(oldTop);
                }
            }
            else
            {
                ThrowExceptionFromError(oldTop);
            }

            return(null);            // Never reached - keeps compiler happy
        }
All Usage Examples Of LuaInterface.LuaDLL::lua_setfenv
LuaDLL