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


C# ILuaState.Insert方法代码示例

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


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

示例1: CO_Resume

		private static int CO_Resume( ILuaState lua )
		{
			ILuaState co = lua.ToThread( 1 );
			lua.L_ArgCheck( co != null, 1, "coroutine expected" );
			int r = AuxResume( lua, co, lua.GetTop() - 1 );
			if( r < 0 )
			{
				lua.PushBoolean( false );
				lua.Insert( -2 );
				return 2; // return false + error message
			}
			else
			{
				lua.PushBoolean( true );
				lua.Insert( -(r+1) );
				return r+1; // return true + `resume' returns
			}
		}
开发者ID:Jornason,项目名称:UniLua,代码行数:18,代码来源:LuaCoroLib.cs

示例2: CO_AuxWrap

 private static int CO_AuxWrap( ILuaState lua )
 {
     ILuaState co = lua.ToThread( lua.UpvalueIndex(1) );
     int r = AuxResume( lua, co, lua.GetTop() );
     if( r < 0 )
     {
         if( lua.IsString( -1 ) ) // error object is a string?
         {
             lua.L_Where( 1 ); // add extra info
             lua.Insert( -2 );
             lua.Concat( 2 );
         }
         lua.Error();
     }
     return r;
 }
开发者ID:matthewyang,项目名称:UniLua,代码行数:16,代码来源:LuaCoroLib.cs

示例3: LoadAux

 private static int LoadAux( ILuaState lua, ThreadStatus status )
 {
     if( status == ThreadStatus.LUA_OK )
         return 1;
     else
     {
         lua.PushNil();
         lua.Insert(-2); // put before error message
         return 2; // return nil plus error message
     }
 }
开发者ID:matthewyang,项目名称:UniLua,代码行数:11,代码来源:LuaBaseLib.cs

示例4: B_PCall

        public static int B_PCall( ILuaState lua )
        {
            lua.L_CheckAny( 1 );
            lua.PushNil();
            lua.Insert( 1 ); // create space for status result

            ThreadStatus status = lua.PCallK( lua.GetTop() - 2,
                LuaDef.LUA_MULTRET, 0, 0, PCallContinuation );

            return FinishPCall( lua, status == ThreadStatus.LUA_OK );
        }
开发者ID:matthewyang,项目名称:UniLua,代码行数:11,代码来源:LuaBaseLib.cs

示例5: LoadAux

		private static int LoadAux( ILuaState lua, ThreadStatus status, int envidx )
		{
			if( status == ThreadStatus.LUA_OK )
			{
				if( envidx != 0 ) // `env' parameter?
				{
					lua.PushValue(envidx); // push `env' on stack
					if( lua.SetUpvalue(-2, 1) == null ) // set `env' as 1st upvalue of loaded function
					{
						lua.Pop(1); // remove `env' if not used by previous call
					}
				}
				return 1;
			}
			else // error (message is on top of the stack)
			{
				lua.PushNil();
				lua.Insert(-2); // put before error message
				return 2; // return nil plus error message
			}
		}
开发者ID:Jornason,项目名称:UniLua,代码行数:21,代码来源:LuaBaseLib.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: LL_Require

		private static int LL_Require( ILuaState lua )
		{
			string name = lua.L_CheckString( 1 );
			lua.SetTop( 1 );
			// _LOADED table will be at index 2
			lua.GetField( LuaDef.LUA_REGISTRYINDEX, "_LOADED" );
			// _LOADED[name]
			lua.GetField( 2, name );
			// is it there?
			if( lua.ToBoolean( -1 ) )
				return 1; // package is already loaded
			// else must load package
			// remove `GetField' result
			lua.Pop( 1 );
			FindLoader( lua, name );
			lua.PushString( name ); // pass name as arg to module loader
			lua.Insert( -2 ); // name is 1st arg (before search data)
			lua.Call( 2, 1 ); // run loader to load module
			if( !lua.IsNil( -1 ) ) // non-nil return?
				lua.SetField( 2, name ); // _LOADED[name] = returned value
			lua.GetField( 2, name );
			if( lua.IsNil( -1 ) ) // module did not set a value?
			{
				lua.PushBoolean( true ); // use true as result
				lua.PushValue( -1 ); // extra copy to be returned
				lua.SetField( 2, name ); // _LOADED[name] = true
			}
			return 1;
		}
开发者ID:bharath1097,项目名称:UniLua,代码行数:29,代码来源:LuaPkgLib.cs

示例8: multiline

 /*
 ** Read multiple lines until a complete Lua statement
 */
 static LuaStatus multiline(ILuaState L)
 {
     for (; ; )
     {  /* repeat until gets a complete statement */
         int len;
         String line = L.ToLString(1, out len);  /* get what it has */
         LuaStatus status = L.LoadBuffer(line, len, "=stdin");  /* try it */
         if (0 == incomplete(L, status) || 0 == pushline(L, false))
         {
             lua_saveline(L, line);  /* keep history */
             return status;  /* cannot or should not try to add continuation line */
         }
         L.PushLiteral("\n");  /* add newline... */
         L.Insert(-2);  /* ...between the two lines */
         L.Concat(3);  /* join them */
     }
 }
开发者ID:ygrenier,项目名称:LuaN,代码行数:20,代码来源:Program.cs

示例9: l_print

 /*
 ** Prints (calling the Lua 'print' function) any values on the stack
 */
 static void l_print(ILuaState L)
 {
     int n = L.GetTop();
     if (n > 0)
     {  /* any result to be printed? */
         L.CheckStack(L.MinStack, "too many results to print");
         L.GetGlobal("print");
         L.Insert(1);
         if (L.PCall(n, 0, 0) != LuaStatus.OK)
             l_message(L, progname, L.PushFString("error calling 'print' (%s)", L.ToString(-1)));
     }
 }
开发者ID:ygrenier,项目名称:LuaN,代码行数:15,代码来源:Program.cs

示例10: docall

 /*
 ** Interface to 'lua_pcall', which sets appropriate message function
 ** and C-signal handler. Used to run all chunks.
 */
 static LuaStatus docall(ILuaState L, int narg, int nres)
 {
     LuaStatus status = 0;
     int base_ = L.GetTop() - narg;  /* function index */
     L.PushFunction(msghandler);  /* push message handler */
     L.Insert(base_);  /* put it under function and args */
     globalL = L;  /* to be available to 'laction' */
     Console.CancelKeyPress += Console_CancelKeyPress;
     //signal(SIGINT, laction);  /* set C-signal handler */
     status = L.PCall(narg, nres, base_);
     //signal(SIGINT, SIG_DFL); /* reset C-signal handler */
     Console.CancelKeyPress -= Console_CancelKeyPress;
     L.Remove(base_);  /* remove message handler from the stack */
     return status;
 }
开发者ID:ygrenier,项目名称:LuaN,代码行数:19,代码来源:Program.cs

示例11: Lua_pcall

    /// <summary>
    /// 为啥加这个这是个神奇的问题
    /// </summary>
    /// <param name="lua"></param>
    /// <returns></returns>
    private int Lua_pcall(ILuaState lua)
    {
        if (lua.Type(1) != LuaType.LUA_TFUNCTION)
        {
            lua.PushBoolean(false);
            //lua.PushString(lua.PrintLuaStack("pcall failed parm 1 function. excepted."));
            return 2;
        }

        int nCount = lua.GetTop();
        lua.PushValue(1);
        for (int i = 2; i <= nCount; ++i)
        {
            lua.PushValue(i);
        }
        if (lua.PCall(nCount - 1,0,0) != 0)
        {
            lua.PushBoolean(false);
            lua.Insert(-2);
            return 2;
        }
        lua.PushBoolean(true);
        return 1;
    }
开发者ID:cedar-x,项目名称:unilua_story,代码行数:29,代码来源:LuaContex.cs


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