当前位置: 首页>>代码示例>>C#>>正文


C# LuaTable.push方法代码示例

本文整理汇总了C#中LuaInterface.LuaTable.push方法的典型用法代码示例。如果您正苦于以下问题:C# LuaTable.push方法的具体用法?C# LuaTable.push怎么用?C# LuaTable.push使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LuaInterface.LuaTable的用法示例。


在下文中一共展示了LuaTable.push方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Resume

        public int Resume(object[] args, LuaTable env)
        {
            int result = 0;
			int oldTop = LuaDLL.lua_gettop(L);

            // If thread isn't started, it needs to be restarted
            if( start )
            {
				start = false;
                func.push( L );
				
				if (env != null)
	            {
	                env.push(L);
	                LuaDLL.lua_setfenv(L, -2);
	            }
				
                result = resume(args, oldTop);

            }
            // If thread is suspended, resume it
            else if( IsSuspended() )
            {
                result = resume(args, oldTop);
            }

            return result;
        }
开发者ID:ylyking,项目名称:UnityHotUpdate,代码行数:28,代码来源:Lua.cs

示例2: DoFile

        /*
         * Excutes a Lua file and returns all the chunk's return
         * values in an array
         */
        public object[] DoFile(string fileName, LuaTable env)
        {            
            LuaDLL.lua_pushstdcallcfunction(L,tracebackFunction);
            int oldTop=LuaDLL.lua_gettop(L);

            // Load with Unity3D resources            
            byte[] text = LuaStatic.Load(fileName);

            if (text == null)
            {
                ThrowExceptionFromError(oldTop);
            }

            //Encoding.UTF8.GetByteCount(text)
            if (LuaDLL.luaL_loadbuffer(L, text, text.Length, fileName) == 0)
            {
                if (env != null)
                {
                    env.push(L);
                    //LuaDLL.lua_setfenv(L, -1);
                    LuaDLL.lua_setfenv(L, -2);
                }                

                if (LuaDLL.lua_pcall(L, 0, -1, -2) == 0)
                {
                    object[] results = translator.popValues(L, oldTop);
                    LuaDLL.lua_pop(L, 1);
                    return results;
                }
                else
                {
                    ThrowExceptionFromError(oldTop);
                }
            }
            else
            {
                ThrowExceptionFromError(oldTop);
            }

            return null;            // Never reached - keeps compiler happy
        }
开发者ID:ylyking,项目名称:UnityHotUpdate,代码行数:45,代码来源:Lua.cs

示例3: DoString

        /// <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
        }
开发者ID:ylyking,项目名称:UnityHotUpdate,代码行数:30,代码来源:Lua.cs

示例4: LoadString

        /// <summary>
        ///
        /// </summary>
        /// <param name="chunk"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public LuaFunction LoadString(string chunk, string name, LuaTable env)
        {
            int oldTop = LuaDLL.lua_gettop(L);
            byte[] bt = Encoding.UTF8.GetBytes(chunk);

            if (LuaDLL.luaL_loadbuffer(L, bt, bt.Length, name) != 0)
                ThrowExceptionFromError(oldTop);

            if (env != null)
            {
                env.push(L);
                LuaDLL.lua_setfenv(L, -2);
            }

            LuaFunction result = translator.getFunction(L, -1);
            translator.popValues(L, oldTop);

            return result;            
        }
开发者ID:ylyking,项目名称:UnityHotUpdate,代码行数:25,代码来源:Lua.cs

示例5: SetMetaTable

 public void SetMetaTable(LuaTable metaTable)
 {
     push(_Interpreter.L);
     metaTable.push(_Interpreter.L);
     LuaDLL.lua_setmetatable(_Interpreter.L, -2);
     LuaDLL.lua_pop(_Interpreter.L, 1);
 }
开发者ID:sysuyedong,项目名称:LuaForUnity,代码行数:7,代码来源:LuaTable.cs

示例6: DoString

        /// <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)
        {
			//Returns the index of the top element in the stack. Because indices start at 1, 
			//this result is equal to the number of elements in the stack;
			//in particular, 0 means an empty stack.
            int oldTop = LuaDLL.lua_gettop(L);   

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


			//Loads a Lua chunk without running it. 
			//If there are no errors, lua_load pushes the compiled chunk as a Lua function on top of the stack. 
			//Otherwise, it pushes an error message.
            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);
                }

				//However, if there is any error, lua_pcall catches it, pushes a single value on the stack (the error message),and returns an error code. 
				//Like lua_call, lua_pcall always removes the function and its arguments from the stack.
                if (LuaDLL.lua_pcall(L, 0, -1, 0) == 0)
					//Revert to the state before call trunk
                    return translator.popValues(L, oldTop);
                else
                    ThrowExceptionFromError(oldTop);
            }
            else
                ThrowExceptionFromError(oldTop);

            return null;            // Never reached - keeps compiler happy
        }
开发者ID:chasing2moro,项目名称:U3D-Lua-Learning,代码行数:41,代码来源:Lua.cs


注:本文中的LuaInterface.LuaTable.push方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。