• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# ILuaState类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


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


示例17: B_DoFile

 public static int B_DoFile( ILuaState lua )
 {
     string filename = lua.L_OptString( 1, null );
     lua.SetTop( 1 );
     if( lua.L_LoadFile( filename ) != ThreadStatus.LUA_OK )
         lua.Error();
     lua.CallK( 0, LuaDef.LUA_MULTRET, 0, DoFileContinuation );
     return DoFileContinuation( lua );
 }
开发者ID:matthewyang,项目名称:UniLua,代码行数:9,代码来源:LuaBaseLib.cs


示例18: WidgetWriteOper

 protected virtual bool WidgetWriteOper(ILuaState lua, string key)
 {
     switch (key)
     {
         case "typeinfo":
             Debug.LogWarning("LuaObject set typeinfo failed ready only!");
             return true;
     }
     return false;
 }
开发者ID:cedar-x,项目名称:unilua_story,代码行数:10,代码来源:StoryGame.cs


示例19: FFI_AddAssembly

 private static int FFI_AddAssembly( ILuaState lua )
 {
     var name = lua.ToString(1);
     var assembly = Assembly.Load( name );
     if( assembly != null )
         AssemblyList.Add( assembly );
     else
         UnityEngine.Debug.LogError("assembly not found:" + name);
     return 0;
 }
开发者ID:matthewyang,项目名称:UniLua,代码行数:10,代码来源:LuaFFILib.cs


示例20: OpenLib

        public static int OpenLib( ILuaState lua )
        {
            NameFuncPair[] define = new NameFuncPair[]
            {
                new NameFuncPair("clock", 	OS_Clock),
            };

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IMAPSimulator类代码示例发布时间:2022-05-24
下一篇:
C# ILookup类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap