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


C# ILuaState.L_CheckType方法代码示例

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


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

示例1: TBL_Concat

		private static int TBL_Concat( ILuaState lua )
		{
			string sep = lua.L_OptString( 2, "" );
			lua.L_CheckType( 1, LuaType.LUA_TTABLE );
			int i = lua.L_OptInt( 3, 1 );
			int last = lua.L_Opt( lua.L_CheckInteger, 4, lua.L_Len(1) );

			StringBuilder sb = new StringBuilder();
			for( ; i<last; ++i )
			{
				lua.RawGetI( 1, i );
				if( !lua.IsString(-1) )
					lua.L_Error(
						"invalid value ({0}) at index {1} in table for 'concat'",
						lua.L_TypeName(-1), i );
				sb.Append( lua.ToString(-1) );
				sb.Append( sep );
				lua.Pop( 1 );
			}
			if( i == last ) // add last value (if interval was not empty)
			{
				lua.RawGetI( 1, i );
				if( !lua.IsString(-1) )
					lua.L_Error(
						"invalid value ({0}) at index {1} in table for 'concat'",
						lua.L_TypeName(-1), i );
				sb.Append( lua.ToString(-1) );
				lua.Pop( 1 );
			}
			lua.PushString( sb.ToString() );
			return 1;
		}
开发者ID:jaydenh,项目名称:UniLua,代码行数:32,代码来源:LuaTableLib.cs

示例2: 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

示例3: TBL_MaxN

		private static int TBL_MaxN( ILuaState lua )
		{
			double max = 0.0;
			lua.L_CheckType( 1, LuaType.LUA_TTABLE );

			lua.PushNil(); // first key
			while( lua.Next(1) )
			{
				lua.Pop( 1 ); // remove value
				if( lua.Type( -1 ) == LuaType.LUA_TNUMBER ) {
					double v = lua.ToNumber( -1 );
					if( v > max ) max = v;
				}
			}
			lua.PushNumber( max );
			return 1;
		}
开发者ID:jaydenh,项目名称:UniLua,代码行数:17,代码来源:LuaTableLib.cs

示例4: PairsMeta

        private static int PairsMeta( ILuaState lua, string method, bool isZero
			, CSharpFunctionDelegate iter )
        {
            if( !lua.L_GetMetaField( 1, method ) ) // no metamethod?
            {
                lua.L_CheckType( 1, LuaType.LUA_TTABLE );
                lua.PushCSharpFunction( iter );
                lua.PushValue( 1 );
                if( isZero )
                    lua.PushInteger( 0 );
                else
                    lua.PushNil();
            }
            else
            {
                lua.PushValue( 1 );
                lua.Call( 1, 3 );
            }
            return 3;
        }
开发者ID:matthewyang,项目名称:UniLua,代码行数:20,代码来源:LuaBaseLib.cs

示例5: B_SetMetaTable

 public static int B_SetMetaTable( ILuaState lua )
 {
     LuaType t = lua.Type( 2 );
     lua.L_CheckType( 1, LuaType.LUA_TTABLE );
     lua.L_ArgCheck( t == LuaType.LUA_TNIL || t == LuaType.LUA_TTABLE,
         2, "nil or table expected" );
     if( lua.L_GetMetaField( 1, "__metatable" ) )
         return lua.L_Error( "cannot change a protected metatable" );
     lua.SetTop( 2 );
     lua.SetMetaTable( 1 );
     return 1;
 }
开发者ID:matthewyang,项目名称:UniLua,代码行数:12,代码来源:LuaBaseLib.cs

示例6: B_RawSet

 public static int B_RawSet( ILuaState lua )
 {
     lua.L_CheckType( 1, LuaType.LUA_TTABLE );
     lua.L_CheckAny( 2 );
     lua.L_CheckAny( 3 );
     lua.SetTop( 3 );
     lua.RawSet( 1 );
     return 1;
 }
开发者ID:matthewyang,项目名称:UniLua,代码行数:9,代码来源:LuaBaseLib.cs

示例7: Str_Dump

		private static int Str_Dump( ILuaState lua )
		{
			lua.L_CheckType( 1, LuaType.LUA_TFUNCTION );
			lua.SetTop( 1 );
			var bsb = new ByteStringBuilder();
			LuaWriter writeFunc = 
				delegate(byte[] bytes, int start, int length)
			{
				bsb.Append(bytes, start, length);
				return DumpStatus.OK;
			};
			if( lua.Dump( writeFunc ) != DumpStatus.OK )
				return lua.L_Error( "unable to dump given function" );
			lua.PushString( bsb.ToString() );
			return 1;
		}
开发者ID:Jornason,项目名称:UniLua,代码行数:16,代码来源:LuaStrLib.cs

示例8: AuxGetN

		private static int AuxGetN( ILuaState lua, int n )
		{
			lua.L_CheckType( n, LuaType.LUA_TTABLE );
			return lua.L_Len( n );
		}
开发者ID:jaydenh,项目名称:UniLua,代码行数:5,代码来源:LuaTableLib.cs

示例9: TBL_Sort

		private static int TBL_Sort( ILuaState lua )
		{
			int n = AuxGetN(lua, 1);
			lua.L_CheckStack(40, "");  /* assume array is smaller than 2^40 */
			if (!lua.IsNoneOrNil(2))  /* is there a 2nd argument? */
				lua.L_CheckType( 2, LuaType.LUA_TFUNCTION );
			lua.SetTop(2);  /* make sure there is two arguments */
			AuxSort(lua, 1, n);
			return 0;
		}
开发者ID:jaydenh,项目名称:UniLua,代码行数:10,代码来源:LuaTableLib.cs

示例10: TBL_Unpack

		private static int TBL_Unpack( ILuaState lua )
		{
			lua.L_CheckType( 1, LuaType.LUA_TTABLE );
			int i = lua.L_OptInt( 2, 1 );
			int e = lua.L_OptInt( 3, lua.L_Len(1) );
			if( i > e ) return 0; // empty range
			int n = e - i + 1; // number of elements
			if( n <= 0 || !lua.CheckStack(n) ) // n <= 0 means arith. overflow
				return lua.L_Error( "too many results to unpack" );
			lua.RawGetI( 1, i ); // push arg[i] (avoiding overflow problems
			while( i++ < e ) // push arg[i + 1...e]
				lua.RawGetI( 1, i );
			return n;
		}
开发者ID:jaydenh,项目名称:UniLua,代码行数:14,代码来源:LuaTableLib.cs


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