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


C# ILuaState.GetField方法代码示例

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


在下文中一共展示了ILuaState.GetField方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
 }
开发者ID:LostTemple1990,项目名称:TouHouExploding,代码行数:25,代码来源:EffectLib.cs

示例2: 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;
 }
开发者ID:LostTemple1990,项目名称:TouHouExploding,代码行数:9,代码来源:SkillDataDriven.cs

示例3: 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;
 }
开发者ID:LostTemple1990,项目名称:TouHouExploding,代码行数:31,代码来源:EffectLib.cs

示例4: 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;
 }
开发者ID:LostTemple1990,项目名称:TouHouExploding,代码行数:19,代码来源:TestLuaLib.cs

示例5: OpenLib

		public static int OpenLib( ILuaState lua )
		{
			NameFuncPair[] define = new NameFuncPair[]
			{
				new NameFuncPair( "concat", 	TBL_Concat 	),
				new NameFuncPair( "maxn", 		TBL_MaxN 	),
				new NameFuncPair( "insert", 	TBL_Insert 	),
				new NameFuncPair( "pack", 		TBL_Pack 	),
				new NameFuncPair( "unpack", 	TBL_Unpack 	),
				new NameFuncPair( "remove", 	TBL_Remove 	),
				new NameFuncPair( "sort", 		TBL_Sort 	),
			};

			lua.L_NewLib( define );

#if LUA_COMPAT_UNPACK
			// _G.unpack = table.unpack
			lua.GetField( -1, "unpack" );
			lua.SetGlobal( "unpack" );
#endif

			return 1;
		}
开发者ID:jaydenh,项目名称:UniLua,代码行数:23,代码来源:LuaTableLib.cs

示例6: WidgetWriteOper

        protected override bool WidgetWriteOper(ILuaState lua, string key)
        {
            switch (key)
            {
                case "target":
                    LuaObject obj = LuaObject.GetLuaObject(lua, 3);
                    if (obj != null)
                        target = obj.transform;
                    else
                        target = null;
                    break;
                case "type":
                    type = (CameraCastType)lua.ToInteger(3);
                    return true;
                case "depth":
                    _camera.depth = lua.ToInteger(3);
                    return true;
                case "distance":
                    m_normalInfo.distance = lua.ToInteger(3);
                    return true;
                case "LRAngle":
                    SetLRAngle((float)lua.L_CheckNumber(3));
                    return true;
                case "UDAngle":
                    SetUDAngle((float)lua.L_CheckNumber(3));
                    return true;
                case "offsetX":
                    m_normalInfo.offSet.x = (float)lua.L_CheckNumber(3);
                    return true;
                case "offsetY":
                    m_normalInfo.offSet.y = (float)lua.L_CheckNumber(3);
                    return true;
                case "offsetZ":
                    m_normalInfo.offSet.z = (float)lua.L_CheckNumber(3);
                    return true;
                case "offset":
                    {
                        if (lua.Type(3) != LuaType.LUA_TTABLE)
                        {
                            Debug.LogWarning("LuaGameCamera set offset attribute parm table excepted.");
                            return true;
                        }
                        Vector3 ve = m_normalInfo.offSet;

                        lua.GetField(3, "x");
                        ve.x = (float)lua.L_CheckNumber(-1);
                        lua.Pop(1);

                        lua.GetField(3, "y");
                        ve.y = (float)lua.L_CheckNumber(-1);
                        lua.Pop(1);

                        lua.GetField(3, "z");
                        ve.z = (float)lua.L_CheckNumber(-1);
                        lua.Pop(1);

                        m_normalInfo.offSet= ve;
                    }
                    return true;
            }
            //return false;
            return base.WidgetWriteOper(lua, key);
        }
开发者ID:cedar-x,项目名称:unilua_story,代码行数:63,代码来源:LuaGameCamera.cs

示例7: WidgetWriteOper

        protected override bool WidgetWriteOper(ILuaState lua, string key)
        {
            switch (key)
            {
                case "visible":
                    Visible = lua.ToBoolean(3);
                    return true;
                case "direction":
                    SetDirection((float)lua.L_CheckNumber(3));
                    return true;
                case "type":
                    SetEntityType((EntityType)lua.L_CheckInteger(3));
                    return true;
                case "scale":
                    SetLocalScale((float)lua.L_CheckNumber(3));
                    return true;
                case "highlightcolor":
                    if (lua.Type(3) != LuaType.LUA_TTABLE)
                    {
                        Debug.LogWarning("Entity hightlightcolor attribute parm table excepted.");
                        return true;
                    }

                    lua.GetField(3, "r");
                    _highlightColor.r = (float)lua.L_CheckNumber(-1);
                    lua.Pop(1);

                    lua.GetField(3, "g");
                    _highlightColor.g = (float)lua.L_CheckNumber(-1);
                    lua.Pop(1);

                    lua.GetField(3, "b");
                    _highlightColor.b = (float)lua.L_CheckNumber(-1);
                    lua.Pop(1);

                    lua.GetField(3, "a");
                    //_highlightColor.a = (float)lua.L_CheckNumber(-1);
                    float a = (float)lua.L_CheckNumber(-1);
                    lua.Pop(1);
                    //print("***** Entity highlight color " + _highlightColor);
                    return true;
            }

            return base.WidgetWriteOper(lua, key);
        }
开发者ID:cedar-x,项目名称:unilua_story,代码行数:45,代码来源:Entity.cs

示例8: LL_Require

		private static int LL_Require( ILuaState lua )
		{
			string name = lua.L_CheckString( 1 );
			lua.SetTop( 1 );
			// _LOADED table will be at index 2
			lua.GetField( LuaDef.LUA_REGISTRYINDEX, "_LOADED" );
			// _LOADED[name]
			lua.GetField( 2, name );
			// is it there?
			if( lua.ToBoolean( -1 ) )
				return 1; // package is already loaded
			// else must load package
			// remove `GetField' result
			lua.Pop( 1 );
			FindLoader( lua, name );
			lua.PushString( name ); // pass name as arg to module loader
			lua.Insert( -2 ); // name is 1st arg (before search data)
			lua.Call( 2, 1 ); // run loader to load module
			if( !lua.IsNil( -1 ) ) // non-nil return?
				lua.SetField( 2, name ); // _LOADED[name] = returned value
			lua.GetField( 2, name );
			if( lua.IsNil( -1 ) ) // module did not set a value?
			{
				lua.PushBoolean( true ); // use true as result
				lua.PushValue( -1 ); // extra copy to be returned
				lua.SetField( 2, name ); // _LOADED[name] = true
			}
			return 1;
		}
开发者ID:bharath1097,项目名称:UniLua,代码行数:29,代码来源:LuaPkgLib.cs

示例9: 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
			}
		}
开发者ID:bharath1097,项目名称:UniLua,代码行数:34,代码来源:LuaPkgLib.cs

示例10: FindFile

		private static string FindFile( ILuaState lua,
			string name, string pname, string dirsep )
		{
			lua.GetField( lua.UpvalueIndex(1), pname );
			string path = lua.ToString( -1 );
			if( path == null )
				lua.L_Error( "'package.{0}' must be a string", pname );
			return SearchPath( lua, name, path, ".", dirsep );
		}
开发者ID:bharath1097,项目名称:UniLua,代码行数:9,代码来源:LuaPkgLib.cs

示例11: SearcherPreload

		private static int SearcherPreload( ILuaState lua )
		{
			string name = lua.L_CheckString( 1 );
			lua.GetField( LuaDef.LUA_REGISTRYINDEX, "_PRELOAD" );
			lua.GetField( -1, name );
			if( lua.IsNil(-1) ) // not found?
				lua.PushString( string.Format(
					"\n\tno field package.preload['{0}']", name ) );
			return 1;
		}
开发者ID:bharath1097,项目名称:UniLua,代码行数:10,代码来源:LuaPkgLib.cs

示例12: noEnv

		private static bool noEnv( ILuaState lua )
		{
			lua.GetField( LuaDef.LUA_REGISTRYINDEX, "LUA_NOENV" );
			bool res = lua.ToBoolean( -1 );
			lua.Pop( 1 );
			return res;
		}
开发者ID:bharath1097,项目名称:UniLua,代码行数:7,代码来源:LuaPkgLib.cs

示例13: GetTableString

 public static string GetTableString(ILuaState lua, int index, string field)
 {
     string str = null;
     lua.GetField(index, field);
     if (lua.Type(-1) == LuaType.LUA_TSTRING)
     {
         str = lua.ToString(-1);
     }
     lua.Pop(1);
     return str;
 }
开发者ID:cedar-x,项目名称:unilua_story,代码行数:11,代码来源:LuaContex.cs

示例14: GetTableNumber

 public static float GetTableNumber(ILuaState lua,int index,string field)
 {
     float fNumber = 0;
     lua.GetField(index, field);
     if (lua.Type(-1) == LuaType.LUA_TNUMBER)
     {
         fNumber = (float)lua.ToNumber(-1);
     }
     lua.Pop(1);
     return fNumber;
 }
开发者ID:cedar-x,项目名称:unilua_story,代码行数:11,代码来源:LuaContex.cs


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