本文整理汇总了C#中ILuaState.Replace方法的典型用法代码示例。如果您正苦于以下问题:C# ILuaState.Replace方法的具体用法?C# ILuaState.Replace怎么用?C# ILuaState.Replace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ILuaState
的用法示例。
在下文中一共展示了ILuaState.Replace方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FinishPCall
private static int FinishPCall( ILuaState lua, bool status )
{
lua.PushBoolean( status );
lua.Replace( 1 );
return lua.GetTop();
}
示例2: B_XPCall
public static int B_XPCall( ILuaState lua )
{
int n = lua.GetTop();
lua.L_ArgCheck( n>=2, 2, "value expected" );
lua.PushValue( 1 ); // exchange function...
lua.Copy( 2, 1); // ...and error handler
lua.Replace( 2 );
ThreadStatus status = lua.PCallK( n-2, LuaDef.LUA_MULTRET,
1, 0, PCallContinuation );
return FinishPCall( lua, status == ThreadStatus.LUA_OK );
}
示例3: FinishPCall
private static int FinishPCall( ILuaState lua, bool status )
{
// no space for extra boolean?
if(!lua.CheckStack(1)) {
lua.SetTop(0); // create space for return values
lua.PushBoolean(false);
lua.PushString("stack overflow");
return 2;
}
lua.PushBoolean( status );
lua.Replace( 1 );
return lua.GetTop();
}
示例4: GmatchAux
private static int GmatchAux( ILuaState lua )
{
MatchState ms = new MatchState();
string src = lua.ToString( lua.UpvalueIndex(1) );
string pattern = lua.ToString( lua.UpvalueIndex(2) );
ms.Lua = lua;
ms.Src = src;
ms.SrcInit = 0;
ms.SrcEnd = src.Length;
ms.Pattern = pattern;
ms.PatternEnd = pattern.Length;
for( int s = lua.ToInteger( lua.UpvalueIndex(3) )
; s <= ms.SrcEnd
; s++ )
{
ms.Level = 0;
int e = Match( ms, s, 0 );
if( e != -1 )
{
int newStart = (e == 0) ? e+1: e;
lua.PushInteger( newStart );
lua.Replace( lua.UpvalueIndex(3) );
return PushCaptures(lua, ms, s, e);
}
}
return 0; // not found
}
示例5: TBL_Pack
private static int TBL_Pack( ILuaState lua )
{
int n = lua.GetTop(); // number of elements to pack
lua.CreateTable( n, 1 ); // create result table
lua.PushInteger( n );
lua.SetField( -2, "n" ); // t.n = number of elements
if( n > 0 ) // at least one element?
{
lua.PushValue( 1 );
lua.RawSetI( -2, 1 ); // insert first element
lua.Replace( 1 ); // move table into index 1
for( int i=n; i>=2; --i ) // assign other elements
lua.RawSetI( 1, i );
}
return 1; // return table
}