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


C# ILuaState.L_OptString方法代码示例

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


在下文中一共展示了ILuaState.L_OptString方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: B_DoFile

 public static int B_DoFile( ILuaState lua )
 {
     string filename = lua.L_OptString( 1, null );
     lua.SetTop( 1 );
     if( lua.L_LoadFile( filename ) != ThreadStatus.LUA_OK )
         lua.Error();
     lua.CallK( 0, LuaDef.LUA_MULTRET, 0, DoFileContinuation );
     return DoFileContinuation( lua );
 }
开发者ID:matthewyang,项目名称:UniLua,代码行数:9,代码来源:LuaBaseLib.cs

示例3: B_CollectGarbage

        public static int B_CollectGarbage( ILuaState lua )
        {
            // not implement gc
            string opt = lua.L_OptString( 1, "collect" );
            switch( opt )
            {
                case "count":
                    lua.PushNumber( 0 );
                    lua.PushNumber( 0 );
                    return 2;

                case "step":
                case "isrunning":
                    lua.PushBoolean( true );
                    return 1;

                default:
                    lua.PushInteger( 0 );
                    return 1;
            }
        }
开发者ID:matthewyang,项目名称:UniLua,代码行数:21,代码来源:LuaBaseLib.cs

示例4: B_Load

        public static int B_Load( ILuaState lua )
        {
            ThreadStatus status;
            int top = lua.GetTop();
            string s = lua.ToString(1);
            string mode = lua.L_OptString(3, "bt");
            if( s != null )
            {
                string chunkName = lua.L_OptString(2, s);
                status = lua.L_LoadBufferX( s, chunkName, mode );
            }
            else // loading from a reader function
            {
                throw new System.NotImplementedException();
            }

            if( status ==  ThreadStatus.LUA_OK && top >= 4 ) // is there an `env' argument
            {
                lua.PushValue(4); // environment for loaded function
                lua.SetUpvalue(-2, 1); // set it as 1st upvalue
            }
            return LoadAux( lua, status );
        }
开发者ID:matthewyang,项目名称:UniLua,代码行数:23,代码来源:LuaBaseLib.cs

示例5: B_Assert

 public static int B_Assert( ILuaState lua )
 {
     if( !lua.ToBoolean( 1 ) )
         return lua.L_Error( "{0}", lua.L_OptString( 2, "assertion failed!" ) );
     return lua.GetTop();
 }
开发者ID:matthewyang,项目名称:UniLua,代码行数:6,代码来源:LuaBaseLib.cs

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

示例7: B_Load

		public static int B_Load( ILuaState lua )
		{
			ThreadStatus status;
			string s = lua.ToString(1);
			string mode = lua.L_OptString(3, "bt");
			int env = (! lua.IsNone(4) ? 4 : 0); // `env' index or 0 if no `env'
			if( s != null )
			{
				string chunkName = lua.L_OptString(2, s);
				status = lua.L_LoadBufferX( s, chunkName, mode );
			}
			else // loading from a reader function
			{
				throw new System.NotImplementedException(); // TODO
			}
			return LoadAux( lua, status, env );
		}
开发者ID:Jornason,项目名称:UniLua,代码行数:17,代码来源:LuaBaseLib.cs

示例8: B_LoadFile

		public static int B_LoadFile( ILuaState lua )
		{
			string fname = lua.L_OptString( 1, null );
			string mode  = lua.L_OptString( 2, null );
			int env = (!lua.IsNone(3) ? 3 : 0); // `env' index or 0 if no `env'
			var status = lua.L_LoadFileX( fname, mode );
			return LoadAux(lua, status, env);
		}
开发者ID:Jornason,项目名称:UniLua,代码行数:8,代码来源:LuaBaseLib.cs


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