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


C# ILuaState.PushValue方法代码示例

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


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

示例1: CreateMetaTable

		private static void CreateMetaTable( ILuaState lua )
		{
			lua.CreateTable(0, 1); // table to be metatable for strings
			lua.PushString( "" ); // dummy string
			lua.PushValue( -2 ); // copy table
			lua.SetMetaTable( -2 ); // set table as metatable for strings
			lua.Pop( 1 );
			lua.PushValue( -2 ); // get string library
			lua.SetField( -2, "__index" ); // metatable.__index = string
			lua.Pop( 1 ); // pop metatable
		}
开发者ID:Jornason,项目名称:UniLua,代码行数:11,代码来源:LuaStrLib.cs

示例2: WidgetWriteOper

        protected override bool WidgetWriteOper(ILuaState lua, string key)
        {
            switch (key)
            {
                case "onFinish":
                    {
                        //lua.L_UnrefRegistry(ref m_pfnFinish);

                        if (lua.Type(3) != LuaType.LUA_TFUNCTION)
                        {
                            return true;
                        }

                        lua.PushValue(3);
                        m_pfnFinish = lua.L_Ref(LuaDef.LUA_REGISTRYINDEX);
                    }
                    return true;
                case "bDestroyOnFinish":
                    m_bDestroyOnFinish = lua.ToBoolean(3);
                    return true;
                case "finishTime":
                    m_fEffectTime = (float)lua.ToNumber(3);
                    return true;
            }
            return base.WidgetWriteOper(lua, key);
        }
开发者ID:cedar-x,项目名称:unilua_story,代码行数:26,代码来源:LuaEffect.cs

示例3: CO_Create

 private static int CO_Create( ILuaState lua )
 {
     lua.L_CheckType( 1, LuaType.LUA_TFUNCTION );
     ILuaState newLua = lua.NewThread();
     lua.PushValue( 1 ); // move function to top
     lua.XMove( newLua, 1 ); // move function from lua to newLua
     return 1;
 }
开发者ID:matthewyang,项目名称:UniLua,代码行数:8,代码来源:LuaCoroLib.cs

示例4: B_Error

 public static int B_Error( ILuaState lua )
 {
     int level = lua.L_OptInt( 2, 1 );
     lua.SetTop( 1 );
     if( lua.IsString( 1 ) && level > 0 )
     {
         lua.L_Where( level );
         lua.PushValue( 1 );
         lua.Concat( 2 );
     }
     return lua.Error();
 }
开发者ID:matthewyang,项目名称:UniLua,代码行数:12,代码来源:LuaBaseLib.cs

示例5: addreturn

 /*
 ** Try to compile line on the stack as 'return <line>'; on return, stack
 ** has either compiled chunk or original line (if compilation failed).
 */
 static LuaStatus addreturn(ILuaState L)
 {
     LuaStatus status;
     int len; string line;
     L.PushLiteral("return ");
     L.PushValue(-2);  /* duplicate line */
     L.Concat(2);  /* new line is "return ..." */
     line = L.ToLString(-1, out len);
     if ((status = L.LoadBuffer(line, len, "=stdin")) == LuaStatus.OK)
     {
         L.Remove(-3);  /* remove original line */
         //line += sizeof("return")/sizeof(char);  /* remove 'return' for history */
         line = line.Substring("return".Length);
         if (!String.IsNullOrEmpty(line))  /* non empty? */
             lua_saveline(L, line);  /* keep history */
     }
     else
         L.Pop(2);  /* remove result from 'luaL_loadbuffer' and new line */
     return status;
 }
开发者ID:ygrenier,项目名称:LuaN,代码行数:24,代码来源:Program.cs

示例6: SerializeTable

 /// <summary>
 /// 将Table序列化成为字符串写入文件
 /// </summary>
 public string SerializeTable(ILuaState _fileLua, int index)
 {
     //获取LibCore中_SerializeTable函数,然后串行化table, 以后要重写,从而不依赖LibCore(因为有在非运行状态下获取内容)
     if (_fileLua.Type(index) != LuaType.LUA_TTABLE)
     {
         Debug.LogWarning("LuaExport:SerializeTable param must a table.. please check");
         return "";
     }
     int dwStackIndex = _fileLua.GetTop();
     _fileLua.PushValue(index);
     _fileLua.GetGlobal("_SerializeTable");
     _fileLua.Insert(-2);
     _fileLua.PushBoolean(false);
     if (_fileLua.PCall(2, 1, 0) != 0)
     {
         Debug.LogWarning(_fileLua.ToString(-1) + " in SerializeTable");
         _fileLua.Pop(-1);
         return "";
     }
     string szResult = _fileLua.ToString(-1);
     //Debug.Log(m_szResult);
     _fileLua.Pop(1);
     if (dwStackIndex != _fileLua.GetTop())
         Debug.LogWarning("LuaExport:SerializeTable stack Exception:start=" + dwStackIndex + " end=" + _fileLua.GetTop());
     return szResult;
 }
开发者ID:cedar-x,项目名称:unilua_story,代码行数:29,代码来源:StoryShotCtrl.cs

示例7: GetVector2

        /// <summary>
        /// 
        /// </summary>
        public static Vector3 GetVector2(ILuaState lua, int dwIndex)
        {
            Vector2 v = Vector2.zero;
            lua.PushValue(dwIndex);
            lua.PushString("x");
            lua.GetTable(-2);
            v.x = (float)lua.ToNumber(-1);
            lua.Pop(1);

            lua.PushString("y");
            lua.GetTable(-2);
            v.y = (float)lua.ToNumber(-1);
            lua.Pop(1);

            lua.Pop(1);

            return v;
        }
开发者ID:cedar-x,项目名称:unilua_story,代码行数:21,代码来源:LuaExport.cs

示例8: AuxSort

		private static void AuxSort( ILuaState lua, int l, int u )
		{
			while( l < u ) // for tail recursion
			{
				// sort elements a[l], a[(l+u)/2] and a[u]
				lua.RawGetI( 1, l );
				lua.RawGetI( 1, u );
				if( SortComp( lua, -1, -2 ) ) // a[u] < a[l]?
					Set2( lua, l, u );
				else
					lua.Pop( 2 );
				if( u-l == 1 ) break; // only 2 elements
				int i = (l+u) / 2;
				lua.RawGetI( 1, i );
				lua.RawGetI( 1, l );
				if( SortComp( lua, -2, -1 ) ) // a[i] < a[l]?
					Set2( lua, i, l );
				else
				{
					lua.Pop( 1 ); // remove a[l]
					lua.RawGetI( 1, u );
					if( SortComp( lua, -1, -2 ) ) // a[u] < a[i]?
						Set2( lua, i, u );
					else
						lua.Pop( 2 );
				}
				if( u-l == 2 ) break; // only 3 arguments
				lua.RawGetI( 1, i ); // Pivot
				lua.PushValue( -1 );
				lua.RawGetI( 1, u-1 );
				Set2(lua, i, u-1);
				/* a[l] <= P == a[u-1] <= a[u], only need to sort from l+1 to u-2 */
				i = l;
				int j = u-1;
				for (;;) {  /* invariant: a[l..i] <= P <= a[j..u] */
					/* repeat ++i until a[i] >= P */
					lua.RawGetI( 1, ++i );
					while( SortComp(lua, -1, -2) )
					{
						if (i>=u) lua.L_Error( "invalid order function for sorting" );
						lua.Pop(1);  /* remove a[i] */
						lua.RawGetI( 1, ++i );
					}
					/* repeat --j until a[j] <= P */
					lua.RawGetI( 1, --j );
					while ( SortComp(lua, -3, -1) ) {
						if (j<=l) lua.L_Error( "invalid order function for sorting" );
						lua.Pop(1);  /* remove a[j] */
						lua.RawGetI( 1, --j );
					}
					if (j<i) {
						lua.Pop(3);  /* pop pivot, a[i], a[j] */
						break;
					}
					Set2(lua, i, j);
				}
				lua.RawGetI( 1, u-1 );
				lua.RawGetI( 1, i );
				Set2(lua, u-1, i);  /* swap pivot (a[u-1]) with a[i] */
				/* a[l..i-1] <= a[i] == P <= a[i+1..u] */
				/* adjust so that smaller half is in [j..i] and larger one in [l..u] */
				if (i-l < u-i) {
					j=l; i=i-1; l=i+2;
				}
				else {
					j=i+1; i=u; u=j-2;
				}
				AuxSort(lua, j, i);  /* call recursively the smaller one */
			}  /* repeat the routine for the larger one */
		}
开发者ID:jaydenh,项目名称:UniLua,代码行数:70,代码来源:LuaTableLib.cs

示例9: ImportProperty

 public void ImportProperty(ILuaState lua, int dwIndex)
 {
     _listCtrl.Clear();
     lua.PushValue(dwIndex);
     int len = lua.L_Len(-1);
     for (int i = 1; i <= len; i++)
     {
         lua.PushNumber(i);
         lua.GetTable(-2);
         lua.PushString("event");
         lua.GetTable(-2);
         string eventName = lua.L_CheckString(-1);
         lua.Pop(1);
         StoryBaseCtrl objCtrl = InstanceEventCtrl(eventName);
         if (objCtrl != null)
         {
             objCtrl.ImportProperty(lua, -1);
             objCtrl.ModInfo();
         }
         else
         {
             Debug.LogWarning("InstanceEventCtrl objCtrl is null " + eventName);
         }
         lua.Pop(1);
         Add(objCtrl);
     }
     lua.Pop(1);
 }
开发者ID:cedar-x,项目名称:unilua_story,代码行数:28,代码来源:StoryShotCtrl.cs

示例10: GetKeyframe

        public static Keyframe GetKeyframe(ILuaState lua, int index)
        {
            Keyframe key = new Keyframe();
            lua.PushValue(index);
            lua.PushString("time");
            lua.GetTable(-2);
            key.time = (float)lua.ToNumber(-1);
            lua.Pop(1);

            lua.PushString("value");
            lua.GetTable(-2);
            key.value = (float)lua.ToNumber(-1);
            lua.Pop(1);

            lua.PushString("inTangent");
            lua.GetTable(-2);
            key.inTangent = (float)lua.ToNumber(-1);
            lua.Pop(1);

            lua.PushString("outTangent");
            lua.GetTable(-2);
            key.outTangent = (float)lua.ToNumber(-1);
            lua.Pop(1);

            lua.Pop(1);
            return key;

        }
开发者ID:cedar-x,项目名称:unilua_story,代码行数:28,代码来源:LuaExport.cs

示例11: MoveControllerAdaptHasHTable

        // zsy add
        private Hashtable MoveControllerAdaptHasHTable(ILuaState lua)
        {
            LuaObjWithCallFun callBackFun = new LuaObjWithCallFun();
            //print("*********** state len" + lua.GetTop());
            Hashtable hashTable = new Hashtable();
            lua.PushValue(3);
            lua.PushNil();
            while (lua.Next(-2))
            {
                string key = lua.L_CheckString(-2);
                switch (key)
                {
                    case "animation":
                        {
                            Hashtable animation = new Hashtable();
                            lua.PushValue(-1);
                            lua.PushNil();

                            float value = 0;
                            string strtype = "ease";
                            bool blean = true;

                            while (lua.Next(-2))
                            {
                                string childkey = lua.L_CheckString(-2);
                                switch (childkey)
                                {
                                    case "onstart":
                                        {
                                            if (lua.Type(-1) == LuaType.LUA_TFUNCTION)
                                            {
                                                lua.PushValue(-1);
                                                callBackFun.dwStartFun = lua.L_Ref(LuaDef.LUA_REGISTRYINDEX);
                                                animation.Add(childkey, childkey);
                                            }
                                            break;
                                        }
                                    case "onupdate":
                                        {
                                            if (lua.Type(-1) == LuaType.LUA_TFUNCTION)
                                            {
                                                lua.PushValue(-1);
                                                callBackFun.dwUpdateFun = lua.L_Ref(LuaDef.LUA_REGISTRYINDEX);

                                                animation.Add(childkey, childkey);
                                            }
                                            break;
                                        }
                                    case "oncomplete":
                                        {
                                            if (lua.Type(-1) == LuaType.LUA_TFUNCTION)
                                            {
                                                lua.PushValue(-1);
                                                callBackFun.dwConpleteFun = lua.L_Ref(LuaDef.LUA_REGISTRYINDEX);

                                                animation.Add(childkey, childkey);
                                            }
                                            break;
                                        }

                                    default:
                                        switch (lua.Type(-1))
                                        {
                                            case LuaType.LUA_TNUMBER:
                                                value = (float)lua.L_CheckNumber(-1);
                                                animation.Add(childkey, value);
                                                break;
                                            case LuaType.LUA_TBOOLEAN:
                                                blean = lua.ToBoolean(-1);
                                                animation.Add(childkey, blean);
                                                break;
                                            case LuaType.LUA_TSTRING:
                                                strtype = lua.L_CheckString(-1);
                                                animation.Add(childkey, strtype);
                                                break;
                                            default:
                                                break;
                                        }
                                        break;
                                }
                                
                                lua.Pop(1);
                            }
                            lua.Pop(1);

                            if (callBackFun.dwConpleteFun != 0)
                            {
                                animation.Add("oncompleteparams", callBackFun);
                            }
                            if (callBackFun.dwStartFun != 0)
                            {
                                animation.Add("onstartparams", callBackFun);
                            }
                            if (callBackFun.dwUpdateFun != 0)
                            {
                                animation.Add("onupdateparams", callBackFun);
                            }

                            animation.Add("onstarttarget", gameObject);
//.........这里部分代码省略.........
开发者ID:cedar-x,项目名称:unilua_story,代码行数:101,代码来源:LuaItween.cs

示例12: B_LoadFile

 public static int B_LoadFile( ILuaState lua )
 {
     string fname = lua.L_OptString( 1, null );
     string mode  = lua.L_OptString( 2, null );
     bool env = ! lua.IsNone( 3 );
     var status = lua.L_LoadFileX( fname, mode );
     if( status != ThreadStatus.LUA_OK && env )
     {
         lua.PushValue( 3 );
         lua.SetUpvalue( -2, 1 ); // put before error message
         return 2;
     }
     return LoadAux( lua, status );
 }
开发者ID:matthewyang,项目名称:UniLua,代码行数:14,代码来源:LuaBaseLib.cs

示例13: ImportProperty

 public void ImportProperty(ILuaState lua, int index)
 {
     lua.PushValue(index);
     lua.PushNil();
     while(lua.Next(-2))
     {
         int key = lua.L_CheckInteger(-2);
         StoryShotCtrl shotctrl = _shots[key-1];
         shotctrl.ImportProperty(lua, -1);
         lua.Pop(1);
     }
     lua.Pop(1);
 }
开发者ID:cedar-x,项目名称:unilua_story,代码行数:13,代码来源:StoryBoardCtrl.cs

示例14: ImportProperty

 public virtual void ImportProperty(ILuaState lua, int index)
 {
     bool bFlag = false;
     lua.PushValue(index);
     lua.PushNil();
     while (lua.Next(-2))
     {
         string key = lua.L_CheckString(-2);
         bFlag = WidgetWriteOper(lua, key);
         if (bFlag == false)
             Debug.LogWarning(luaName + " can't write key:" + key + " please check....");
         lua.Pop(1);
     }
     lua.Pop(1);
 }
开发者ID:cedar-x,项目名称:unilua_story,代码行数:15,代码来源:StoryBaseCtrl.cs

示例15: CreateSearchersTable

		private static void CreateSearchersTable( ILuaState lua )
		{
			CSharpFunctionDelegate[] searchers = new CSharpFunctionDelegate[]
			{
				SearcherPreload,
				SearcherLua,
			};
			lua.CreateTable( searchers.Length, 0 );
			for( int i=0; i<searchers.Length; ++i )
			{
				lua.PushValue( -2 ); // set `package' as upvalue for all searchers
				lua.PushCSharpClosure( searchers[i], 1 );
				lua.RawSetI( -2, i+1 );
			}
		}
开发者ID:bharath1097,项目名称:UniLua,代码行数:15,代码来源:LuaPkgLib.cs


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