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


C# ILuaState类代码示例

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


ILuaState类属于命名空间,在下文中一共展示了ILuaState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OpenLib

		public static int OpenLib( ILuaState lua )
		{
			NameFuncPair[] define = new NameFuncPair[]
			{
				new NameFuncPair( "byte", 		Str_Byte ),
				new NameFuncPair( "char", 		Str_Char ),
				new NameFuncPair( "dump", 		Str_Dump ),
				new NameFuncPair( "find", 		Str_Find ),
				new NameFuncPair( "format", 	Str_Format ),
				new NameFuncPair( "gmatch", 	Str_Gmatch ),
				new NameFuncPair( "gsub", 		Str_Gsub ),
				new NameFuncPair( "len", 		Str_Len ),
				new NameFuncPair( "lower", 		Str_Lower ),
				new NameFuncPair( "match", 		Str_Match ),
				new NameFuncPair( "rep", 		Str_Rep ),
				new NameFuncPair( "reverse", 	Str_Reverse ),
				new NameFuncPair( "sub", 		Str_Sub ),
				new NameFuncPair( "upper", 		Str_Upper ),
			};

			lua.L_NewLib( define );
			CreateMetaTable( lua );

			return 1;
		}
开发者ID:Jornason,项目名称:UniLua,代码行数:25,代码来源:LuaStrLib.cs

示例2: 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

示例3: WidgetReadOper

        protected override bool WidgetReadOper(ILuaState lua, string key)
        {
            switch (key)
            {
                case "speed":
                    lua.PushNumber(_speed);
                    return true;
                case "dwMMethod":
                    lua.PushInteger(_dwMMethod);
                    return true;
                case "bMoving":
                    lua.PushBoolean(_bMoving);
                    return true;
                case "fUpdateInterval":
                    lua.PushNumber(_fUpdateInterval);
                    return true;
                case "fAnimSpeed":
                    if (_animator)
                    {
                        lua.PushNumber(_animator.speed);
                    }
                    else
                    {
                        lua.PushNumber(0);
                    }
                    return true;
            }

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

示例4: addEffectToBuff

 public static int addEffectToBuff(ILuaState luaState)
 {
     SkillEffect effect = (SkillEffect)luaState.ToUserData(-2);
     BuffDataDriven buff = (BuffDataDriven)luaState.ToUserData(-1);
     buff.addEffect(effect);
     return 0;
 }
开发者ID:LostTemple1990,项目名称:TouHouExploding,代码行数:7,代码来源:EffectLib.cs

示例5: 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

示例6: OpenLib

        public static int OpenLib( ILuaState lua )
        {
            var define = new NameFuncPair[]
            {
                new NameFuncPair( "clear_assembly_list", FFI_ClearAssemblyList ),
                new NameFuncPair( "add_assembly", FFI_AddAssembly ),

                new NameFuncPair( "clear_using_list", FFI_ClearUsingList ),
                new NameFuncPair( "using", FFI_Using ),

                new NameFuncPair( "parse_signature", FFI_ParseSignature ),

                new NameFuncPair( "get_type", FFI_GetType ),
                new NameFuncPair( "get_constructor", FFI_GetConstructor ),
                new NameFuncPair( "get_static_method", FFI_GetStaticMethod ),
                new NameFuncPair( "get_method", FFI_GetMethod ),
                new NameFuncPair( "call_method", FFI_CallMethod ),

                new NameFuncPair( "get_field", FFI_GetField ),
                new NameFuncPair( "get_field_value", FFI_GetFieldValue ),
                new NameFuncPair( "set_field_value", FFI_SetFieldValue ),

                new NameFuncPair( "get_prop", FFI_GetProp ),
                new NameFuncPair( "get_static_prop", FFI_GetStaticProp ),
                new NameFuncPair( "get_prop_value", FFI_GetPropValue ),
                new NameFuncPair( "set_prop_value", FFI_SetPropValue ),

                // new NameFuncPair( "call_constructor", FFI_CallConstructor ),
            };

            lua.L_NewLib( define );
            return 1;
        }
开发者ID:matthewyang,项目名称:UniLua,代码行数:33,代码来源:LuaFFILib.cs

示例7: addBuffToUnit

 public static int addBuffToUnit(ILuaState luaState)
 {
     BuffDataDriven buff = (BuffDataDriven)luaState.ToUserData(-2);
     Unit unit = (Unit)luaState.ToUserData(-1);
     unit.addBuff(buff);
     return 0;
 }
开发者ID:LostTemple1990,项目名称:TouHouExploding,代码行数:7,代码来源:EffectLib.cs

示例8: WidgetWriteOper

        protected override bool WidgetWriteOper(ILuaState lua, string key)
        {
            switch (key)
            {
                case "onFinish":
                    {
                        //lua.L_UnrefRegistry(ref m_pfnFinish);

                        if (lua.Type(3) != LuaType.LUA_TFUNCTION)
                        {
                            return true;
                        }

                        lua.PushValue(3);
                        m_pfnFinish = lua.L_Ref(LuaDef.LUA_REGISTRYINDEX);
                    }
                    return true;
                case "bDestroyOnFinish":
                    m_bDestroyOnFinish = lua.ToBoolean(3);
                    return true;
                case "finishTime":
                    m_fEffectTime = (float)lua.ToNumber(3);
                    return true;
            }
            return base.WidgetWriteOper(lua, key);
        }
开发者ID:cedar-x,项目名称:unilua_story,代码行数:26,代码来源:LuaEffect.cs

示例9: FFI_CallMethod

 private static int FFI_CallMethod( ILuaState lua )
 {
     var ffiMethod = (FFIMethodBase)lua.ToUserData(1);
     if (ffiMethod != null)
     {
         try
         {
             return ffiMethod.Call(lua);
         }
         catch( Exception e )
         {
             lua.PushString( "call_method Exception: " + e.Message +
                 "\nSource:\n" + e.Source +
                 "\nStaceTrace:\n" + e.StackTrace );
             lua.Error();
             return 0;
         }
     }
     else
     {
         lua.PushString( "call_method cannot find MethodInfo" );
         lua.Error();
         return 0;
     }
 }
开发者ID:matthewyang,项目名称:UniLua,代码行数:25,代码来源:LuaFFILib.cs

示例10: 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;
		}
开发者ID:jaydenh,项目名称:UniLua,代码行数:32,代码来源:LuaTableLib.cs

示例11: 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;
			}
		}
开发者ID:Jornason,项目名称:UniLua,代码行数:30,代码来源:LuaCoroLib.cs

示例12: CO_Create

 private static int CO_Create( ILuaState lua )
 {
     lua.L_CheckType( 1, LuaType.LUA_TFUNCTION );
     ILuaState newLua = lua.NewThread();
     lua.PushValue( 1 ); // move function to top
     lua.XMove( newLua, 1 ); // move function from lua to newLua
     return 1;
 }
开发者ID:matthewyang,项目名称:UniLua,代码行数:8,代码来源:LuaCoroLib.cs

示例13: Lua_ObjectMetaReader

    private int Lua_ObjectMetaReader(ILuaState lua)
    {
        string key = lua.L_CheckString(2);
        if (WidgetReadOper(lua, key))
            return 1;

        return 0;
    }
开发者ID:cedar-x,项目名称:unilua_story,代码行数:8,代码来源:StoryGame.cs

示例14: initLib

 public static int initLib(ILuaState luaState)
 {
     var define = new NameFuncPair[]
     {
         new NameFuncPair("testLuaCall", testLuaCall),
     };
     luaState.L_NewLib(define);
     return 1;
 }
开发者ID:LostTemple1990,项目名称:TouHouExploding,代码行数:9,代码来源:TestLuaLib.cs

示例15: Lua_ObjectMetaWriter

    private int Lua_ObjectMetaWriter(ILuaState lua)
    {
        string key = lua.L_CheckString(2);
        if (WidgetWriteOper(lua, key))
            return 0;

        lua.RawSet(1);
        return 0;
    }
开发者ID:cedar-x,项目名称:unilua_story,代码行数:9,代码来源:StoryGame.cs


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