本文整理汇总了C#中ILuaState.ToThread方法的典型用法代码示例。如果您正苦于以下问题:C# ILuaState.ToThread方法的具体用法?C# ILuaState.ToThread怎么用?C# ILuaState.ToThread使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ILuaState
的用法示例。
在下文中一共展示了ILuaState.ToThread方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: 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
}
}
示例3: CO_Status
private static int CO_Status( ILuaState lua )
{
ILuaState co = lua.ToThread( 1 );
lua.L_ArgCheck( co != null, 1, "coroutine expected" );
if( (LuaState)lua == (LuaState)co )
lua.PushString( "running" );
else switch( co.Status )
{
case ThreadStatus.LUA_YIELD:
lua.PushString( "suspended" );
break;
case ThreadStatus.LUA_OK:
{
LuaDebug ar = new LuaDebug();
if( co.GetStack( 0, ar ) ) // does it have frames?
lua.PushString( "normal" );
else if( co.GetTop() == 0 )
lua.PushString( "dead" );
else
lua.PushString( "suspended" );
break;
}
default: // some error occurred
lua.PushString( "dead" );
break;
}
return 1;
}