本文整理汇总了C#中ILuaState.Pop方法的典型用法代码示例。如果您正苦于以下问题:C# ILuaState.Pop方法的具体用法?C# ILuaState.Pop怎么用?C# ILuaState.Pop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ILuaState
的用法示例。
在下文中一共展示了ILuaState.Pop方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: applyTranslate
public static int applyTranslate(ILuaState luaState)
{
if (luaState.IsTable(-1))
{
TranslateResult transRes = new TranslateResult();
// 位移目标
luaState.GetField(-1, "target");
transRes.target = (Unit)luaState.ToUserData(-1);
luaState.Pop(1);
// 行偏移量
luaState.GetField(-1, "offsetRow");
transRes.offsetRow = luaState.ToInteger(-1);
luaState.Pop(1);
// 列偏移量
luaState.GetField(-1, "offsetCol");
transRes.offsetCol = luaState.ToInteger(-1);
luaState.Pop(1);
//// 位移原因
//luaState.GetField(-1, "translateReason");
//transRes. = luaState.ToInteger(-1);
//luaState.Pop(1);
ProcessManager.getInstance().addResult(transRes);
}
return 0;
}
示例2: 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;
}
示例3: CreateMetaTable
private static void CreateMetaTable( ILuaState lua )
{
lua.CreateTable(0, 1); // table to be metatable for strings
lua.PushString( "" ); // dummy string
lua.PushValue( -2 ); // copy table
lua.SetMetaTable( -2 ); // set table as metatable for strings
lua.Pop( 1 );
lua.PushValue( -2 ); // get string library
lua.SetField( -2, "__index" ); // metatable.__index = string
lua.Pop( 1 ); // pop metatable
}
示例4: AuxResume
private static int AuxResume( ILuaState lua, ILuaState co, int narg )
{
if(!co.CheckStack(narg)) {
lua.PushString("too many arguments to resume");
return -1; // error flag
}
if( co.Status == ThreadStatus.LUA_OK && co.GetTop() == 0 )
{
lua.PushString( "cannot resume dead coroutine" );
return -1; // error flag
}
lua.XMove( co, narg );
ThreadStatus status = co.Resume( lua, narg );
if( status == ThreadStatus.LUA_OK || status == ThreadStatus.LUA_YIELD )
{
int nres = co.GetTop();
if(!lua.CheckStack(nres+1)) {
co.Pop(nres); // remove results anyway;
lua.PushString("too many results to resume");
return -1; // error flag
}
co.XMove( lua, nres ); // move yielded values
return nres;
}
else
{
co.XMove( lua, 1 ); // move error message
return -1;
}
}
示例5: Awake
void Awake() {
Debug.Log("LuaScriptController Awake");
if( Lua == null )
{
Lua = LuaAPI.NewState();
Lua.L_OpenLibs();
var status = Lua.L_DoFile( LuaScriptFile );
if( status != ThreadStatus.LUA_OK )
{
throw new Exception( Lua.ToString(-1) );
}
if( ! Lua.IsTable(-1) )
{
throw new Exception(
"framework main's return value is not a table" );
}
AwakeRef = StoreMethod( "awake" );
StartRef = StoreMethod( "start" );
UpdateRef = StoreMethod( "update" );
LateUpdateRef = StoreMethod( "late_update" );
FixedUpdateRef = StoreMethod( "fixed_update" );
Lua.Pop(1);
Debug.Log("Lua Init Done");
}
CallMethod( AwakeRef );
}
示例6: testLuaCall
public static int testLuaCall(ILuaState luaState)
{
bool arg2 = luaState.ToBoolean(-1);
luaState.GetField(1, "n");
int len = luaState.ToInteger(-1);
luaState.Pop(1);
int sum = 0;
for (int i=0;i<len;i++)
{
luaState.PushInteger(i + 1);
luaState.GetTable(1);
sum += luaState.ToInteger(-1);
luaState.Pop(1);
}
Thread.Sleep(5000);
luaState.PushInteger(sum);
Debug.Log(sum);
return 1;
}
示例7: initSkill
public void initSkill(ILuaState luaState)
{
if ( !luaState.IsTable(-1) )
{
Debug.Log(this._skillId + ".lua does not return a table!");
}
this._cost = storeMethod(luaState,"cost");
luaState.Pop(1);
// 主动效果
// 被动效果
}
示例8: applyDamage
public static int applyDamage(ILuaState luaState)
{
if (luaState.IsTable(-1))
{
DamageResult dmgRes = new DamageResult();
// 攻击者
luaState.GetField(-1, "attacker");
dmgRes.attacker = (Unit)luaState.ToUserData(-1);
luaState.Pop(1);
// 受害者
luaState.GetField(-1, "victim");
dmgRes.victim = (Unit)luaState.ToUserData(-1);
luaState.Pop(1);
// 伤害
luaState.GetField(-1, "physicalDamage");
dmgRes.physicalDamage = luaState.ToInteger(-1);
luaState.Pop(1);
luaState.GetField(-1, "spellDamage");
dmgRes.spellDamage = luaState.ToInteger(-1);
luaState.Pop(1);
luaState.GetField(-1, "hpRemoval");
dmgRes.hpRemoval = luaState.ToInteger(-1);
luaState.Pop(1);
// 伤害原因
luaState.GetField(-1, "damageReason");
dmgRes.damageReason = (BattleConsts.DamageReason)luaState.ToInteger(-1);
luaState.Pop(1);
ProcessManager.getInstance().addResult(dmgRes);
}
return 0;
}
示例9: GetLuaObject
public static LuaObject GetLuaObject(ILuaState lua, int index)
{
// if(lua.Type(index) != LuaType.LUA_TTABLE)
// {
// return null;
// }
//
// lua.PushValue(index);
// lua.PushString("_ref");
// lua.GetTable(-2);
// LuaObject obj = lua.ToUserData(-1).Target as LuaObject;
LuaObject obj = null;
lua.Pop(2);
return obj;
}
示例10: 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;
}
示例11: addreturn
/*
** Try to compile line on the stack as 'return <line>'; on return, stack
** has either compiled chunk or original line (if compilation failed).
*/
static LuaStatus addreturn(ILuaState L)
{
LuaStatus status;
int len; string line;
L.PushLiteral("return ");
L.PushValue(-2); /* duplicate line */
L.Concat(2); /* new line is "return ..." */
line = L.ToLString(-1, out len);
if ((status = L.LoadBuffer(line, len, "=stdin")) == LuaStatus.OK)
{
L.Remove(-3); /* remove original line */
//line += sizeof("return")/sizeof(char); /* remove 'return' for history */
line = line.Substring("return".Length);
if (!String.IsNullOrEmpty(line)) /* non empty? */
lua_saveline(L, line); /* keep history */
}
else
L.Pop(2); /* remove result from 'luaL_loadbuffer' and new line */
return status;
}
示例12: Awake
void Awake() {
Debug.Log("LuaScriptController Awake");
if( Lua == null )
{
Lua = LuaAPI.NewState();
Lua.L_OpenLibs();
var status = Lua.L_DoFile( LuaScriptFile );
if( status != ThreadStatus.LUA_OK )
{
throw new Exception( Lua.ToString(-1) );
}
if( ! Lua.IsTable(-1) )
{
throw new Exception(
"framework main's return value is not a table" );
}
AwakeRef = StoreMethod( "awake" );
StartRef = StoreMethod( "start" );
UpdateRef = StoreMethod( "update" );
LateUpdateRef = StoreMethod( "late_update" );
FixedUpdateRef = StoreMethod( "fixed_update" );
Lua.Pop(1);
Debug.Log("Lua Init Done");
}
Lua.GetGlobal("xxsmain");
if (Lua.PCall(0, 0, 0) != ThreadStatus.LUA_OK)
{
Debug.LogWarning("Call global function xxsmain failed:" + Lua.ToString(-1));
Lua.Pop(1);
}
Debug.Log("dofile main...........");
CallMethod( AwakeRef );
}
示例13: GetMethodAux
private static int GetMethodAux( ILuaState lua, BindingFlags flags )
{
var t = (Type)lua.ToUserData(1);
var mname = lua.ToString(2);
var n = lua.RawLen(3);
var types = new Type[n];
for( int i=0; i<n; ++i )
{
lua.RawGetI( 3, i+1 );
types[i] = (Type)lua.ToUserData(-1);
lua.Pop(1);
}
var minfo = t.GetMethod( mname,
flags,
null,
CallingConventions.Any,
types,
null
);
if( minfo == null )
{
return 0;
}
else
{
var ffiMethod = new FFIMethodInfo(minfo);
lua.PushLightUserData( ffiMethod );
return 1;
}
}
示例14: noEnv
private static bool noEnv( ILuaState lua )
{
lua.GetField( LuaDef.LUA_REGISTRYINDEX, "LUA_NOENV" );
bool res = lua.ToBoolean( -1 );
lua.Pop( 1 );
return res;
}
示例15: FFI_GetConstructor
private static int FFI_GetConstructor( ILuaState lua )
{
var t = (Type)lua.ToUserData(1);
var n = lua.RawLen(2);
var types = new Type[n];
for( int i=0; i<n; ++i )
{
lua.RawGetI( 2, i+1 );
types[i] = (Type)lua.ToUserData(-1);
lua.Pop( 1 );
}
var cinfo = t.GetConstructor( types );
var ffiMethod = new FFIConstructorInfo(cinfo);
lua.PushLightUserData( ffiMethod );
return 1;
}