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


C# ILuaState.SetField方法代码示例

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


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

示例1: OpenLib

		internal static int OpenLib( ILuaState lua )
		{
			NameFuncPair[] define = new NameFuncPair[]
			{
				new NameFuncPair( "assert", 		LuaBaseLib.B_Assert ),
				new NameFuncPair( "collectgarbage", LuaBaseLib.B_CollectGarbage ),
				new NameFuncPair( "dofile", 		LuaBaseLib.B_DoFile ),
				new NameFuncPair( "error", 			LuaBaseLib.B_Error ),
				new NameFuncPair( "ipairs", 		LuaBaseLib.B_Ipairs ),
				new NameFuncPair( "loadfile", 		LuaBaseLib.B_LoadFile ),
				new NameFuncPair( "load", 			LuaBaseLib.B_Load ),
				new NameFuncPair( "loadstring", 	LuaBaseLib.B_Load ),
				new NameFuncPair( "next", 			LuaBaseLib.B_Next ),
				new NameFuncPair( "pairs", 			LuaBaseLib.B_Pairs ),
				new NameFuncPair( "pcall", 			LuaBaseLib.B_PCall ),
				new NameFuncPair( "print", 			LuaBaseLib.B_Print ),
				new NameFuncPair( "rawequal", 		LuaBaseLib.B_RawEqual ),
				new NameFuncPair( "rawlen", 		LuaBaseLib.B_RawLen ),
				new NameFuncPair( "rawget", 		LuaBaseLib.B_RawGet ),
				new NameFuncPair( "rawset", 		LuaBaseLib.B_RawSet ),
				new NameFuncPair( "select", 		LuaBaseLib.B_Select ),
				new NameFuncPair( "getmetatable", 	LuaBaseLib.B_GetMetaTable ),
				new NameFuncPair( "setmetatable", 	LuaBaseLib.B_SetMetaTable ),
				new NameFuncPair( "tonumber", 		LuaBaseLib.B_ToNumber ),
				new NameFuncPair( "tostring", 		LuaBaseLib.B_ToString ),
				new NameFuncPair( "type", 			LuaBaseLib.B_Type ),
				new NameFuncPair( "xpcall", 		LuaBaseLib.B_XPCall ),
			};

			// set global _G
			lua.PushGlobalTable();
			lua.PushGlobalTable();
			lua.SetField( -2, "_G" );

			// open lib into global lib
			lua.L_SetFuncs( define, 0 );
			// lua.RegisterGlobalFunc( "type", 	LuaBaseLib.B_Type );
			// lua.RegisterGlobalFunc( "pairs", 	LuaBaseLib.B_Pairs );
			// lua.RegisterGlobalFunc( "ipairs", 	LuaBaseLib.B_Ipairs );
			// lua.RegisterGlobalFunc( "print",	LuaBaseLib.B_Print );
			// lua.RegisterGlobalFunc( "tostring",	LuaBaseLib.B_ToString );

			lua.PushString( LuaDef.LUA_VERSION );
			lua.SetField( -2, "_VERSION" );

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

示例2: OpenLib

		public static int OpenLib( ILuaState lua )
		{
			NameFuncPair[] define = new NameFuncPair[]
			{
				new NameFuncPair( "abs",   		Math_Abs ),
				new NameFuncPair( "acos",  		Math_Acos ),
				new NameFuncPair( "asin",  		Math_Asin ),
				new NameFuncPair( "atan2", 		Math_Atan2 ),
				new NameFuncPair( "atan",  		Math_Atan ),
				new NameFuncPair( "ceil",  		Math_Ceil ),
				new NameFuncPair( "cosh",  		Math_Cosh ),
				new NameFuncPair( "cos",   		Math_Cos ),
				new NameFuncPair( "deg",   		Math_Deg ),
				new NameFuncPair( "exp",   		Math_Exp ),
				new NameFuncPair( "floor", 		Math_Floor ),
				new NameFuncPair( "fmod",  		Math_Fmod ),
				new NameFuncPair( "frexp", 		Math_Frexp ),
				new NameFuncPair( "ldexp", 		Math_Ldexp ),
				new NameFuncPair( "log10", 		Math_Log10 ),
				new NameFuncPair( "log",   		Math_Log ),
				new NameFuncPair( "max",   		Math_Max ),
				new NameFuncPair( "min",   		Math_Min ),
				new NameFuncPair( "modf",  		Math_Modf ),
				new NameFuncPair( "pow",   		Math_Pow ),
				new NameFuncPair( "rad",   		Math_Rad ),
				new NameFuncPair( "random",     Math_Random ),
				new NameFuncPair( "randomseed", Math_RandomSeed ),
				new NameFuncPair( "sinh", 		Math_Sinh ),
				new NameFuncPair( "sin",   		Math_Sin ),
				new NameFuncPair( "sqrt",  		Math_Sqrt ),
				new NameFuncPair( "tanh",   	Math_Tanh ),
				new NameFuncPair( "tan",   		Math_Tan ),
			};

			lua.L_NewLib( define );

			lua.PushNumber( Math.PI );
			lua.SetField( -2, "pi" );

			lua.PushNumber( Double.MaxValue );
			lua.SetField( -2, "huge" );

			RandObj = new Random();

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

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

示例4: OpenLib

		public static int OpenLib( ILuaState lua )
		{
			var define = new NameFuncPair[]
			{
				new NameFuncPair( "encode", ENC_Encode ),
				new NameFuncPair( "decode", ENC_Decode ),
			};

			lua.L_NewLib( define );

			lua.PushString( ENC_UTF8 );
			lua.SetField( -2, "utf8" );

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

示例5: Lua_virtualPos

 int Lua_virtualPos(ILuaState lua)
 {
     float dis = (float)lua.L_CheckInteger(2);
     float lr = (float)lua.L_CheckInteger(3);
     float ud = (float)lua.L_CheckInteger(4);
     Vector3 vpos = virtualPos(dis, lr, ud);
     lua.NewTable();
     lua.PushNumber(vpos.x);
     lua.SetField(-2, "x");
     lua.PushNumber(vpos.y);
     lua.SetField(-2, "y");
     lua.PushNumber(vpos.z);
     lua.SetField(-2, "z");
     return 1;
 }
开发者ID:cedar-x,项目名称:unilua_story,代码行数:15,代码来源:LuaGameCamera.cs

示例6: SetProgDir

		private static void SetPath
			( ILuaState lua
			, string 	fieldName
			, string 	envName1
			, string	envName2
			, string 	def
			)
		{
            lua.PushString(def);
            /*
			string path = Environment.GetEnvironmentVariable( envName1 );
			if( path == null ) // no environment variable?
				path = Environment.GetEnvironmentVariable( envName2 ); // try alternative name
			if( path == null || noEnv( lua ) ) // no environment variable?
				lua.PushString( def );
			else
			{
				// replace ";;" by ";AUXMARK;" and then AUXMARK by default path
				lua.L_Gsub( path, LUA_PATH_SEP + LUA_PATH_SEP,
					LUA_PATH_SEP + AUXMARK + LUA_PATH_SEP );
				lua.L_Gsub( path, AUXMARK, def );
				lua.Remove( -2 );
			}*/
			SetProgDir( lua );
			lua.SetField( -2, fieldName );
		}
开发者ID:bharath1097,项目名称:UniLua,代码行数:26,代码来源:LuaPkgLib.cs

示例7: QuaternionToStack

 public static void QuaternionToStack(ILuaState lua, Quaternion qat)
 {
     lua.NewTable();
     lua.PushNumber(qat.x);
     lua.SetField(-2, "x");
     lua.PushNumber(qat.y);
     lua.SetField(-2, "y");
     lua.PushNumber(qat.z);
     lua.SetField(-2, "z");
     lua.PushNumber(qat.w);
     lua.SetField(-2, "w");
 }
开发者ID:cedar-x,项目名称:unilua_story,代码行数:12,代码来源:LuaExport.cs

示例8: WidgetReadOper

 protected override bool WidgetReadOper(ILuaState lua, string key)
 {
     switch (key)
     {
         case "type":
             lua.PushInteger((int)type);
             return true;
         case "depth":
             lua.PushInteger((int)_camera.depth);
             return true;
         case "distance":
             lua.PushNumber(m_normalInfo.distance);
             return true;
         case "parent":
             LuaObject pParent = transform.parent.GetComponent<LuaObject>();
             pParent.RefLua();
             pParent.PushThis(lua);
             return true;
         case "ml_target":
             LuaObject mpParent = ml_Target.GetComponent<LuaObject>();
             mpParent.RefLua();
             mpParent.PushThis(lua);
             return true;
         case "target":
             if (m_Target != null)
             {
                 LuaObject tar = m_Target.GetComponent<LuaObject>();
                 if (tar != null)
                     tar.PushThis(lua);
                 return true;
             }
             return false;
         case "LRAngle":
             lua.PushNumber(m_normalInfo.rotationLR);
             return true;
         case "UDAngle":
             lua.PushNumber(m_normalInfo.rotationUD);
             return true;
         case "offsetX":
             lua.PushNumber(m_normalInfo.offSet.x);
             return true;
         case "offsetY":
             lua.PushNumber(m_normalInfo.offSet.y);
             return true;
         case "offsetZ":
             lua.PushNumber(m_normalInfo.offSet.z);
             return true;
         case "offset":
             lua.NewTable();
             lua.PushNumber(m_normalInfo.offSet.x);
             lua.SetField(-2, "x");
             lua.PushNumber(m_normalInfo.offSet.y);
             lua.SetField(-2, "y");
             lua.PushNumber(m_normalInfo.offSet.z);
             lua.SetField(-2, "z");
             return true;
     }
     //return false;
     return base.WidgetReadOper(lua, key);
 }
开发者ID:cedar-x,项目名称:unilua_story,代码行数:60,代码来源:LuaGameCamera.cs

示例9: WidgetReadOper

        protected override bool WidgetReadOper(ILuaState lua, string key)
        {
            switch (key)
            {
                case "visible":
                    lua.PushBoolean(Visible);
                    return true;
                case "direction":
                    lua.PushNumber(GetDirection());
                    return true;
                case "type":
                    lua.PushInteger((int)GetEntityType());
                    return true;
                case "scale":
                    lua.PushNumber(transform.localScale.x);
                     return true;
                case "height":
                    lua.PushNumber(m_height);
                    return true;
                case "radius":
                    lua.PushNumber(m_Radius);
                    return true;
                case "highlightcolor":
                    lua.NewTable();
                     
                    lua.PushNumber(_highlightColor.r);
                    lua.SetField(-2,"r");

                    lua.PushNumber(_highlightColor.g);
                    lua.SetField(-2,"g");

                    lua.PushNumber(_highlightColor.b);
                    lua.SetField(-2,"b");

                    lua.PushNumber(_highlightColor.a);
                    lua.SetField(-2,"a");
                    return true;
            }

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

示例10: TBL_Pack

		private static int TBL_Pack( ILuaState lua )
		{
			int n = lua.GetTop(); // number of elements to pack
			lua.CreateTable( n, 1 ); // create result table
			lua.PushInteger( n );
			lua.SetField( -2, "n" ); // t.n = number of elements
			if( n > 0 ) // at least one element?
			{
				lua.PushValue( 1 );
				lua.RawSetI( -2, 1 ); // insert first element
				lua.Replace( 1 ); // move table into index 1
				for( int i=n; i>=2; --i ) // assign other elements
					lua.RawSetI( 1, i );
			}
			return 1; // return table
		}
开发者ID:jaydenh,项目名称:UniLua,代码行数:16,代码来源:LuaTableLib.cs

示例11: Vector3ToStack

 public static void Vector3ToStack(ILuaState lua, Vector3 v3)
 {
     lua.NewTable();
     lua.PushNumber(v3.x);
     lua.SetField(-2, "x");
     lua.PushNumber(v3.y);
     lua.SetField(-2, "y");
     lua.PushNumber(v3.z);
     lua.SetField(-2, "z");
 }
开发者ID:cedar-x,项目名称:unilua_story,代码行数:10,代码来源:LuaExport.cs

示例12: OpenLib

		public static int OpenLib( ILuaState lua )
		{
			// NameFuncPair[] define = new NameFuncPair[]
			// {
			// 	new NameFuncPair( "module", PKG_Module ),
			// };

			// lua.L_NewLib( define );
			
			// // create table CLIBS to keep track of loaded C libraries
			// lua.L_GetSubTable( LuaDef.LUA_REGISTRYINDEX, CLIBS );
			// lua.CreateTable( 0, 1 ); // metatable for CLIBS
			// lua.PushCSharpFunction
			
			// create `package' table
			NameFuncPair[] pkg_define = new NameFuncPair[]
			{
				new NameFuncPair( "loadlib", 	PKG_LoadLib ),
				new NameFuncPair( "searchpath", PKG_SearchPath ),
				new NameFuncPair( "seeall", 	PKG_SeeAll ),
			};
			lua.L_NewLib( pkg_define );

			CreateSearchersTable( lua );
#if LUA_COMPAT_LOADERS
			lua.PushValue( -1 ); // make a copy of `searchers' table
			lua.SetField( -3, "loaders" ); // put it in field `loaders'
#endif
			lua.SetField( -2, "searchers" ); // put it in field `searchers'

			// set field `path'
			SetPath( lua, "path", LUA_PATHVERSION, LUA_PATH, LUA_PATH_DEFAULT );
			// set field `cpath'
			SetPath( lua, "cpath", LUA_CPATHVERSION, LUA_CPATH, LUA_CPATH_DEFAULT );

			// store config information
			lua.PushString( string.Format("{0}\n{1}\n{2}\n{3}\n{4}\n",
				LuaConf.LUA_DIRSEP,
				LUA_PATH_SEP,
				LUA_PATH_MARK,
				LUA_EXEC_DIR,
				LUA_IGMARK ) );
			lua.SetField( -2, "config" );

			// set field `loaded'
			lua.L_GetSubTable( LuaDef.LUA_REGISTRYINDEX, "_LOADED" );
			lua.SetField( -2, "loaded" );

			// set field `preload'
			lua.L_GetSubTable( LuaDef.LUA_REGISTRYINDEX, "_PRELOAD" );
			lua.SetField( -2, "preload" );

			lua.PushGlobalTable();
			lua.PushValue( -2 ); // set `package' as upvalue for next lib

			NameFuncPair[] loadLibFuncs = new NameFuncPair[]
			{
				new NameFuncPair( "module", 	LL_Module ),
				new NameFuncPair( "require", 	LL_Require ),
			};
			lua.L_SetFuncs( loadLibFuncs, 1 ); // open lib into global table
			lua.Pop( 1 ); // pop global table

			return 1; // return `package' table
		}
开发者ID:bharath1097,项目名称:UniLua,代码行数:65,代码来源:LuaPkgLib.cs

示例13: ColorToStack

 public static void ColorToStack(ILuaState lua, Color cr)
 {
     lua.NewTable();
     lua.PushNumber(cr.r);
     lua.SetField(-2, "r");
     lua.PushNumber(cr.g);
     lua.SetField(-2, "g");
     lua.PushNumber(cr.b);
     lua.SetField(-2, "b");
     lua.PushNumber(cr.a);
     lua.SetField(-2, "a");
 }
开发者ID:cedar-x,项目名称:unilua_story,代码行数:12,代码来源:LuaExport.cs

示例14: ExportProperty

 public virtual void ExportProperty(ILuaState lua, int index)
 {
     lua.NewTable();
     bool bSet = false;
     foreach (string key in expList)
     {
         bSet = WidgetReadOper(lua, key);
         if (bSet == true)
         {
             lua.SetField(-2, key);
         }
     }
 }
开发者ID:cedar-x,项目名称:unilua_story,代码行数:13,代码来源:StoryBaseCtrl.cs

示例15: WidgetReadOper

        protected override bool WidgetReadOper(ILuaState lua, string key)
        {
            switch (key)
            {
                case "speedArr"://lsy add
                    //Debug.Log("-----------SPEED------READ-----------");
                    CameraPathSpeedList slist = _cameraPath.speedList;
                    lua.NewTable();
                    for (int i = 1; i <= slist.realNumberOfPoints; i++)
                    {     
                        CameraPathSpeed spd = slist[i - 1];
                        lua.PushNumber(i);
                        lua.NewTable();

                        lua.PushInteger((int)spd.positionModes);
                        lua.SetField(-2, "positionModes");//free or FixedToPoint

                        lua.PushNumber(spd.percent);
                        lua.SetField(-2, "percent");

                        lua.PushNumber(spd.speed);
                        lua.SetField(-2, "speed");

                        lua.PushNumber(spd.curvePercentage);
                        lua.SetField(-2, "curvePercentage");
                        if (spd.point != null)
                        {
                            lua.PushInteger(spd.point.index);
                            lua.SetField(-2, "point");
                        }    
                        if (spd.cpointA != null)
                        {
                            lua.PushInteger(spd.cpointA.index);
                            lua.SetField(-2, "cpointA");
                        }
                        if (spd.cpointB != null)
                        {
                            lua.PushInteger(spd.cpointB.index);
                            lua.SetField(-2, "cpointB");
                        }
                     
                        lua.SetTable(-3);
                    }
                    break;
                case "isLoop"://
                    lua.PushBoolean(_cameraPath.loop);
                    break;
                case "dwType":
                    lua.PushInteger(2);
                    break;
                case "interpolation":
                    lua.PushInteger((int)_cameraPath.interpolation);
                    break;
                case "animMode":
                    lua.PushInteger((int)_cameraAnimator.animationMode);
                    break;
                case "speed":
                    lua.PushNumber(_cameraAnimator.pathSpeed);
                    break;
                case "controlpoints":
                    lua.NewTable();
                    for (int i = 1; i <= _cameraPath.realNumberOfPoints; i++)
                    {
                        lua.PushNumber(i);
                        lua.NewTable();
                        Vector3ToStack(lua, _cameraPath[i-1].localPosition);
                        lua.SetField(-2, "controlpoint");
                        Vector3ToStack(lua, _cameraPath[i - 1].forwardControlPoint);
                        lua.SetField(-2, "forwardControlPoint");
                        Vector3ToStack(lua, _cameraPath[i - 1].backwardControlPoint);
                        lua.SetField(-2, "backwardControlPoint");
                        lua.SetTable(-3);
                    }
                    break;
                case "Orientations":
                    CameraPathOrientationList ori = _cameraPath.orientationList;
                    lua.NewTable();
                    for (int i = 1; i <= ori.realNumberOfPoints; i++)
                    {
                        CameraPathOrientation pathOri = ori[i-1];
                        lua.PushNumber(i);
                        QuaternionToStack(lua, pathOri.rotation);
                        lua.PushInteger((int)pathOri.positionModes);
                        lua.SetField(-2, "positionModes");
                        lua.PushNumber(pathOri.percent);
                        lua.SetField(-2, "percent");
                        lua.PushNumber(pathOri.curvePercentage);
                        lua.SetField(-2, "curvePercentage");
                        
                        if (pathOri.point != null)
                        {
                            lua.PushInteger(pathOri.point.index);
                            lua.SetField(-2, "point");
                        }
                        if (pathOri.cpointA != null)
                        {
                            lua.PushInteger(pathOri.cpointA.index);
                            lua.SetField(-2, "cpointA");
                        }
                        if (pathOri.cpointB != null)
//.........这里部分代码省略.........
开发者ID:cedar-x,项目名称:unilua_story,代码行数:101,代码来源:LuaPathCamera.cs


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