本文整理汇总了C#中ILuaState.IsFunction方法的典型用法代码示例。如果您正苦于以下问题:C# ILuaState.IsFunction方法的具体用法?C# ILuaState.IsFunction怎么用?C# ILuaState.IsFunction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ILuaState
的用法示例。
在下文中一共展示了ILuaState.IsFunction方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: storeMethod
private int storeMethod(ILuaState luaState, string name)
{
luaState.GetField(-1, "cost");
if (luaState.IsFunction(-1))
{
return luaState.L_Ref(LuaDef.LUA_REGISTRYINDEX);
}
return 0;
}
示例2: setEffectTarget
public static int setEffectTarget(ILuaState luaState)
{
SkillEffect effect = (SkillEffect)luaState.ToUserData(-2);
if (effect == null)
{
throw new ArgumentException("effect is null!");
}
int target = 0;
if ( !luaState.IsFunction(-1) )
{
throw new ArgumentException("effect target is not a function!");
}
target = luaState.L_Ref(LuaDef.LUA_REGISTRYINDEX);
effect.setTarget(target);
return 0;
}
示例3: FindLoader
private static void FindLoader( ILuaState lua, string name )
{
// will be at index 3
lua.GetField( lua.UpvalueIndex(1), "searchers" );
if( ! lua.IsTable(3) )
lua.L_Error("'package.searchers' must be a table");
var sb = new StringBuilder();
// iterator over available searchers to find a loader
for( int i=1; ; ++i )
{
lua.RawGetI( 3, i ); // get a searcher
if( lua.IsNil( -1 ) ) // no more searchers?
{
lua.Pop( 1 ); // remove nil
lua.PushString( sb.ToString() );
lua.L_Error( "module '{0}' not found:{1}",
name, lua.ToString(-1));
return;
}
lua.PushString( name );
lua.Call( 1, 2 ); // call it
if( lua.IsFunction(-2) ) // did it find a loader
return; // module loader found
else if( lua.IsString(-2) ) // searcher returned error message?
{
lua.Pop( 1 ); // return extra return
sb.Append( lua.ToString(-1) );
}
else
lua.Pop( 2 ); // remove both returns
}
}