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


C# Lua.GetTable方法代码示例

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


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

示例1: SetTableObjectField1

		public void SetTableObjectField1 ()
		{
			using (Lua lua = new Lua ()) {
				lua.DoString ("a={b={c=\"test\"}}");
				LuaTable tab = lua.GetTable ("a.b");
				TestClass t1 = new TestClass ();
				t1.testval = 4;
				tab ["c"] = t1;
				TestClass t2 = (TestClass)lua ["a.b.c"];
				//Console.WriteLine("a.b.c="+t2.testval);
				Assert.AreEqual (4, t2.testval);
				Assert.AreEqual (t1 , t2);
			}
		}
开发者ID:The-Megax,项目名称:NLua,代码行数:14,代码来源:LuaTests.cs

示例2: GetTableStringField1

		public void GetTableStringField1 ()
		{
			using (Lua lua = new Lua ()) {
				lua.DoString ("a={b={c=\"test\"}}");
				LuaTable tab = lua.GetTable ("a.b");
				string str = (string)tab ["c"];
				//Console.WriteLine("a.b.c="+str);
				Assert.AreEqual (str, "test");
			}
		}
开发者ID:The-Megax,项目名称:NLua,代码行数:10,代码来源:LuaTests.cs

示例3: SetTableStringField2

		public void SetTableStringField2 ()
		{
			using (Lua lua = new Lua ()) {
				lua.DoString ("a={b={c=\"test\"}}");
				LuaTable tab = lua.GetTable ("a");
				tab ["b.c"] = "new test";
				string str = lua.GetString ("a.b.c");
				//Console.WriteLine("a.b.c="+str);
				Assert.AreEqual (str, "new test");
			}
		}
开发者ID:The-Megax,项目名称:NLua,代码行数:11,代码来源:LuaTests.cs

示例4: GetTableNumericField1

		public void GetTableNumericField1 ()
		{
			using (Lua lua = new Lua ()) {
				lua.DoString ("a={b={c=2}}");
				LuaTable tab = lua.GetTable ("a.b");
				double num = (double)tab ["c"];
				//Console.WriteLine("a.b.c="+num);
				Assert.AreEqual (num, 2d);
			}
		}
开发者ID:The-Megax,项目名称:NLua,代码行数:10,代码来源:LuaTests.cs

示例5: SetTableNumericField2

		public void SetTableNumericField2 ()
		{
			using (Lua lua = new Lua ()) {
				lua.DoString ("a={b={c=2}}");
				LuaTable tab = lua.GetTable ("a");
				tab ["b.c"] = 3;
				double num = lua.GetNumber ("a.b.c");
				//Console.WriteLine("a.b.c="+num);
				Assert.AreEqual (num, 3d);
			}
		}
开发者ID:The-Megax,项目名称:NLua,代码行数:11,代码来源:LuaTests.cs

示例6: LoadSaveLua

	private void LoadSaveLua(){
		System.Text.Encoding encodeType = System.Text.Encoding.ASCII;
		string loadedFileSave = "";
		string MapPath = PlayerPrefs.GetString("MapsPath", "maps/");

		loadedFileSave = System.IO.File.ReadAllText(ScenarioData.SaveLua.Replace("/maps/", MapPath), encodeType);
		
		string loadedFileFunctions = "";
		loadedFileFunctions = System.IO.File.ReadAllText(StructurePath + "lua_variable_functions.lua", encodeType);
		
		string loadedFileEndFunctions = "";
		loadedFileEndFunctions = System.IO.File.ReadAllText(StructurePath + "lua_variable_end_functions.lua", encodeType);
		
		loadedFileSave = loadedFileFunctions + loadedFileSave + loadedFileEndFunctions;
		
		save = new Lua();
		save.LoadCLRPackage();
		
		try {
			save.DoString(loadedFileSave);
		} catch(NLua.Exceptions.LuaException e) {
			Debug.LogError(FormatException(e), gameObject);
			
			HelperGui.MapLoaded = false;
			return;
		}
		// LoadArea
		ScenarioData.Area = new Rect();
		if(save.GetTable("Scenario.Areas.AREA_1") != null && save.GetTable("Scenario.Areas.AREA_1").ToString() != "null"){
			ScenarioData.DefaultArea = true;
			ScenarioData.Area.x = float.Parse(save.GetTable("Scenario.Areas.AREA_1.rectangle")[1].ToString(), System.Globalization.CultureInfo.InvariantCulture.NumberFormat);
			ScenarioData.Area.y = float.Parse(save.GetTable("Scenario.Areas.AREA_1.rectangle")[2].ToString(), System.Globalization.CultureInfo.InvariantCulture.NumberFormat);
			ScenarioData.Area.width = float.Parse(save.GetTable("Scenario.Areas.AREA_1.rectangle")[3].ToString(), System.Globalization.CultureInfo.InvariantCulture.NumberFormat);
			ScenarioData.Area.height = float.Parse(save.GetTable("Scenario.Areas.AREA_1.rectangle")[4].ToString(), System.Globalization.CultureInfo.InvariantCulture.NumberFormat);
			UpdateArea();
		}
		else{
			ScenarioData.DefaultArea = false;
			HeightmapControler.TerrainMaterial.SetInt("_Area", ScenarioData.DefaultArea?1:0);
			MapElements.SetActive(false);
			HeightmapControler.TerrainMaterial.SetFloat("_AreaX", 0);
			HeightmapControler.TerrainMaterial.SetFloat("_AreaY", 0);
			HeightmapControler.TerrainMaterial.SetFloat("_AreaWidht", ScenarioData.Size.x / 10f);
			HeightmapControler.TerrainMaterial.SetFloat("_AreaHeight", ScenarioData.Size.y / 10f);
		}

		MapCenterPoint = Vector3.zero;
		MapCenterPoint.x = (ScenarioData.Size.x / 20);
		MapCenterPoint.z = -1 * (ScenarioData.Size.y / 20);
		
		// LoadMarkers
		int MarkersCount = save.GetTable("Scenario.MasterChain._MASTERCHAIN_.Markers").Values.Count;
		int SpawnCount = 0;
		int MassCount = 0;
		int HydroCount = 0;
		int SiCount = 0;

		LuaTable MasterChain = save.GetTable("Scenario.MasterChain._MASTERCHAIN_.Markers") as LuaTable;
		Mexes = new List<Mex>();
		Hydros = new List<Hydro>();
		ARMY_ = new List<Army>();
		SiMarkers = new List<Marker>();

		for(int m = 0; m < MarkersCount; m++){
			LuaTable MarkerTab = MasterChain[save.GetTable("AllKeyMarkers")[m + 1].ToString()] as LuaTable;
			LuaTable MarkerPos = MarkerTab["position"] as LuaTable;
			if(MarkerTab["type"].ToString() == "Mass"){
				Mexes.Add(new Mex());
				Mexes[MassCount].name = save.GetTable("AllKeyMarkers")[m + 1].ToString();
				
				Mexes[MassCount].position.x = float.Parse(MarkerPos[1].ToString(), System.Globalization.CultureInfo.InvariantCulture.NumberFormat);
				Mexes[MassCount].position.y = float.Parse(MarkerPos[2].ToString(), System.Globalization.CultureInfo.InvariantCulture.NumberFormat);
				Mexes[MassCount].position.z = float.Parse(MarkerPos[3].ToString(), System.Globalization.CultureInfo.InvariantCulture.NumberFormat);
				
				Mexes[MassCount].SpawnWithArmy = armys.ARMY1;
				if(MarkerTab["position"].ToString() != null && MarkerTab["position"].ToString() != "null"){
					switch(MarkerTab["position"].ToString()){
					case "ARMY_1":
						Mexes[MassCount].SpawnWithArmy = armys.ARMY1;
						break;
					case "ARMY_2":
						Mexes[MassCount].SpawnWithArmy = armys.ARMY2;
						break;
					case "ARMY_3":
						Mexes[MassCount].SpawnWithArmy = armys.ARMY3;
						break;
					case "ARMY_4":
						Mexes[MassCount].SpawnWithArmy = armys.ARMY4;
						break;
					case "ARMY_5":
						Mexes[MassCount].SpawnWithArmy = armys.ARMY5;
						break;
					case "ARMY_6":
						Mexes[MassCount].SpawnWithArmy = armys.ARMY6;
						break;
					case "ARMY_7":
						Mexes[MassCount].SpawnWithArmy = armys.ARMY7;
						break;
					case "ARMY_8":
						Mexes[MassCount].SpawnWithArmy = armys.ARMY8;
//.........这里部分代码省略.........
开发者ID:ZoneBeat,项目名称:FAForeverMapEditor,代码行数:101,代码来源:MapLuaParser.cs

示例7: GetAndSetTable

		public void GetAndSetTable ()
		{
			using (Lua lua = new Lua ()) {
				lua.DoString ("a={b={c=2}}\nb={c=3}");
				LuaTable tab = lua.GetTable ("b");
				lua ["a.b"] = tab;
				double num = lua.GetNumber ("a.b.c");
				//Console.WriteLine("a.b.c="+num);
				Assert.AreEqual (num, 3d);
			}
		}
开发者ID:The-Megax,项目名称:NLua,代码行数:11,代码来源:LuaTests.cs

示例8: LoadScenarioLua

	private void LoadScenarioLua(){
		System.Text.Encoding encodeType = System.Text.Encoding.ASCII;

		string MapPath = PlayerPrefs.GetString("MapsPath", "maps/");

		string loadedFile = "";
		Debug.Log("Load file:" + MapPath + FolderName + "/" + ScenarioFileName + ".lua");
		string loc = MapPath + FolderName + "/" + ScenarioFileName + ".lua";
		loadedFile = System.IO.File.ReadAllText(loc, encodeType);

		string loadedFileFunctions = "";
		loadedFileFunctions = System.IO.File.ReadAllText(StructurePath + "lua_variable_functions.lua", encodeType);
		
		env = new Lua();
		env.LoadCLRPackage();
		
		try {
			env.DoString(loadedFileFunctions + loadedFile);
		} catch(NLua.Exceptions.LuaException e) {
			Debug.LogError(FormatException(e), gameObject);
			
			HelperGui.MapLoaded = false;
			return;
		}
		
		// Load Map Prop
		ScenarioData.MapName = env.GetTable("ScenarioInfo").RawGet("name").ToString();
		ScenarioData.MapDesc = env.GetTable("ScenarioInfo").RawGet("description").ToString();
		ScenarioData.Type = env.GetTable("ScenarioInfo").RawGet("type").ToString();

		if(env.GetTable("ScenarioInfo").RawGet("map_version") != null && env.GetTable("ScenarioInfo").RawGet("map_version").ToString() != "null"){
			ScenarioData.Version = float.Parse(env.GetTable("ScenarioInfo").RawGet("map_version").ToString(), System.Globalization.CultureInfo.InvariantCulture.NumberFormat);
		}
		else{
			ScenarioData.Version = 1;
		}

		if(env.GetTable("ScenarioInfo").RawGet("preview") != null && env.GetTable("ScenarioInfo").RawGet("preview").ToString() != "null"){
			ScenarioData.Preview = env.GetTable("ScenarioInfo").RawGet("preview").ToString();
		}
		else{
			ScenarioData.Preview = "";
		}

		ScenarioData.SaveLua =  env.GetTable("ScenarioInfo").RawGet("save").ToString();
		ScenarioData.Scmap = env.GetTable("ScenarioInfo").RawGet("map").ToString();
		ScenarioData.ScriptLua = env.GetTable("ScenarioInfo").RawGet("script").ToString();
		
		// Load Map Size
		var width = env.GetTable("ScenarioInfo.size")[1].ToString();
		var height = env.GetTable("ScenarioInfo.size")[2].ToString();
		
		ScenarioData.Size.x = float.Parse(width.ToString(), System.Globalization.CultureInfo.InvariantCulture.NumberFormat);
		ScenarioData.Size.y = float.Parse(height.ToString(), System.Globalization.CultureInfo.InvariantCulture.NumberFormat);
		ScenarioData.MaxHeight = 128;
		CamControll.MapSize = Mathf.Max(ScenarioData.Size.x, ScenarioData.Size.y);
		
		// Load Players
		LuaTable TeamsTab = env.GetTable("ScenarioInfo.Configurations.standard.teams")[1] as LuaTable;
		LuaTable ArmyTab = TeamsTab.RawGet("armies") as LuaTable;
		
		ScenarioData.Players = ArmyTab.Values.Count;

		ScenarioData.NoRushRadius = float.Parse(env.GetTable("ScenarioInfo").RawGet("norushradius").ToString(), System.Globalization.CultureInfo.InvariantCulture.NumberFormat);
		ScenarioData.NoRushARMY = new Vector2[ScenarioData.Players];
		
		for(int id = 0; id < ScenarioData.Players; id++) {
			ScenarioData.NoRushARMY[id] = Vector2.zero;
			if(env.GetTable("ScenarioInfo").RawGet("norushoffsetX_ARMY_" + (id + 1)) != null)
				ScenarioData.NoRushARMY[id].x = float.Parse(env.GetTable("ScenarioInfo").RawGet("norushoffsetX_ARMY_" + (id + 1)).ToString(), System.Globalization.CultureInfo.InvariantCulture.NumberFormat);
			if(env.GetTable("ScenarioInfo").RawGet("norushoffsetY_ARMY_" + (id + 1)) != null)
				ScenarioData.NoRushARMY[id].y = float.Parse(env.GetTable("ScenarioInfo").RawGet("norushoffsetY_ARMY_" + (id + 1)).ToString(), System.Globalization.CultureInfo.InvariantCulture.NumberFormat);
		}
	}
开发者ID:ZoneBeat,项目名称:FAForeverMapEditor,代码行数:74,代码来源:MapLuaParser.cs

示例9: CreateBuilding

        /// <summary>
        /// Create a building.
        /// </summary>
        /// <param name="key">The key of the building to create as defined in its .lua file</param>
        /// <param name="position">Position, in pixels, to create the building at</param>
        /// <returns></returns>
        public static Building CreateBuilding(string key, Vector2 position)
        {
            Building Output = new Building();

            lua = new Lua();
            lua.DoFile(GetPath(key));

            if ((string)lua["type"] == "building")
            {
                Output.Name = (string)lua["name"];
                Output.Description = (string)lua["description"];
                //Output.Position = position;
                //Output.Rotation = (float)(double)lua["rotation"];

                #region Drawables
                LuaTable drawables = lua.GetTable("drawableParts");
                Output.BuildingParts = new List<DrawableBuildingPart>(drawables.Values.Count);

                foreach (LuaTable table in drawables.Values)
                {

                    DrawableBuildingPart part = new DrawableBuildingPart();
                    part.Image = Art.LoadImage((string)table["imagePath"]);
                    part.Alpha = (float)(double)table["alpha"];
                    part.Tint = LuaHelper.LuaToColor((LuaTable)table["tint"]);
                    part.Offset = new Vector2((int)(double)table["offsetX"], (int)(double)table["offsetY"]);
                    part.Rotation = (float)(double)table["rotation"];

                    Output.BuildingParts.Add(part);
                    //part.Offset = new Vector2(
                }
                #endregion

                #region Physics
                Output.Body = BodyFactory.CreateBody(World);
                Output.Body.BodyType = BodyType.Dynamic;
                Output.Body.FixedRotation = true;
                Output.Body.Position = Physics.ToMetres(position);

                LuaTable physicsShapes = lua.GetTable("physicsShapes");
                LuaTable rectangles = (LuaTable)physicsShapes["rectangles"];
                foreach (LuaTable table in rectangles.Values)
                {
                    Vector2 centre = new Vector2(
                        Physics.ToMetres((float)(double)table["centreX"]),
                        Physics.ToMetres((float)(double)table["centreY"])
                        );
                    float width = Physics.ToMetres((float)(double)table["width"]);
                    float height = Physics.ToMetres((float)(double)table["height"]);
                    //float rotation = (float)(double)table["rotation"];
                    //Body body = BodyFactory.CreateRectangle(World, width, height, 1, centre);
                    Fixture fix = FixtureFactory.AttachRectangle(width, height, 1, centre, Output.Body);
                    //Fixture fix = new Fixture(
                    //FixtureFactory.
                    //FixtureDef
                    //fix.
                    //body.Rotation = rotation;
                    //Body
                }
                LuaTable circles = (LuaTable)physicsShapes["circles"];
                foreach (LuaTable table in circles)
                {
                    Vector2 centre = new Vector2(
                        Physics.ToMetres((float)(double)table["centreX"]),
                        Physics.ToMetres((float)(double)table["centreY"])
                        );
                    float radius = Physics.ToMetres((float)(double)table["radius"]);
                }
                #endregion
            }
            //lua.

            Buildings.Add(Output);
            return Output;
        }
开发者ID:noogai03sprojects,项目名称:AerialArchitect,代码行数:81,代码来源:BuildingManager.cs

示例10: LoadSaveLua

	private void LoadSaveLua(){
		System.Text.Encoding encodeType = System.Text.Encoding.ASCII;
		string loadedFileSave = "";
		string MapPath = EnvPaths.GetMapsPath();

		loadedFileSave = System.IO.File.ReadAllText(ScenarioData.SaveLua.Replace("/maps/", MapPath), encodeType);

		string loadedFileFunctions = LuaHelper.GetStructureText ("lua_variable_functions.lua");
		//loadedFileFunctions = System.IO.File.ReadAllText(StructurePath + "lua_variable_functions.lua", encodeType);

		string loadedFileEndFunctions = LuaHelper.GetStructureText ("lua_variable_end_functions.lua");
		//loadedFileEndFunctions = System.IO.File.ReadAllText(StructurePath + "lua_variable_end_functions.lua", encodeType);
		
		loadedFileSave = loadedFileFunctions + loadedFileSave + loadedFileEndFunctions;
		
		save = new Lua();
		save.LoadCLRPackage();
		
		try {
			save.DoString(loadedFileSave);
		} catch(NLua.Exceptions.LuaException e) {
			Debug.LogError(ParsingStructureData.FormatException(e), gameObject);
			
			HelperGui.MapLoaded = false;
			return;
		}
		// LoadArea
		ScenarioData.Area = new Rect();
		if(save.GetTable("Scenario.Areas.AREA_1") != null && save.GetTable("Scenario.Areas.AREA_1").ToString() != "null"){
			ScenarioData.DefaultArea = true;
			ScenarioData.Area.x = float.Parse(save.GetTable("Scenario.Areas.AREA_1.rectangle")[1].ToString(), System.Globalization.CultureInfo.InvariantCulture.NumberFormat);
			ScenarioData.Area.y = float.Parse(save.GetTable("Scenario.Areas.AREA_1.rectangle")[2].ToString(), System.Globalization.CultureInfo.InvariantCulture.NumberFormat);
			ScenarioData.Area.width = float.Parse(save.GetTable("Scenario.Areas.AREA_1.rectangle")[3].ToString(), System.Globalization.CultureInfo.InvariantCulture.NumberFormat);
			ScenarioData.Area.height = float.Parse(save.GetTable("Scenario.Areas.AREA_1.rectangle")[4].ToString(), System.Globalization.CultureInfo.InvariantCulture.NumberFormat);
			UpdateArea();
		}
		else{
			ScenarioData.DefaultArea = false;
			HeightmapControler.TerrainMaterial.SetInt("_Area", ScenarioData.DefaultArea?1:0);
			MapElements.SetActive(false);
			HeightmapControler.TerrainMaterial.SetFloat("_AreaX", 0);
			HeightmapControler.TerrainMaterial.SetFloat("_AreaY", 0);
			HeightmapControler.TerrainMaterial.SetFloat("_AreaWidht", ScenarioData.Size.x / 10f);
			HeightmapControler.TerrainMaterial.SetFloat("_AreaHeight", ScenarioData.Size.y / 10f);
		}

		MapCenterPoint = Vector3.zero;
		MapCenterPoint.x = (ScenarioData.Size.x / 20);
		MapCenterPoint.z = -1 * (ScenarioData.Size.y / 20);
		
		// LoadMarkers
		#region Load Markers
		//int MarkersCount = save.GetTable("Scenario.MasterChain._MASTERCHAIN_.Markers").Values.Count;

		Mexes = new List<Mex>();
		Hydros = new List<Hydro>();
		ARMY_ = new List<Army>();
		SiMarkers = new List<Marker>();


		//LuaTable MasterChain = save.GetTable("Scenario.MasterChain._MASTERCHAIN_.Markers") as LuaTable;
		//string[] KeysArray = new string[MarkersCount];
		//MasterChain.Keys.CopyTo(KeysArray, 0);

		LuaHelper.LHTable MarkersTable = new LuaHelper.LHTable(save.GetTable("Scenario.MasterChain._MASTERCHAIN_.Markers"));

		for(int m = 0; m < MarkersTable.Count; m++){
			//LuaTable MarkerTab = MasterChain[KeysArray[m]] as LuaTable;
			LuaHelper.LHTable MarkerTable = new LuaHelper.LHTable(MarkersTable, MarkersTable.Keys[m]);

			Vector3 MarkerPosParsed = Vector3.zero;
			MarkerTable.GetVector3Value("position", out MarkerPosParsed);

			Vector3 MarkerRotParsed = Vector3.zero;
			MarkerTable.GetVector3Value("orientation", out MarkerRotParsed);

			string TypeOfMarker = MarkerTable.GetStringValue("type");

			if(TypeOfMarker == "Mass"){
				Mex newMex = new Mex();
				newMex.name = MarkersTable.Keys[m];
				
				newMex.position = HeightmapControler.MapPosInWorld(MarkerPosParsed);
				newMex.orientation = MarkerRotParsed;
				
				LuaHelper.ReadSpawnWithArmy(out newMex.SpawnWithArmy, MarkerTable);

				Mexes.Add(newMex);
			}
			else if(TypeOfMarker == "Hydrocarbon"){
				Hydro NewHydro = new Hydro();
				NewHydro.name = MarkersTable.Keys[m];

				NewHydro.size = MarkerTable.GetFloatValue("size");
				NewHydro.amount = MarkerTable.GetFloatValue("amount");
				NewHydro.resource = MarkerTable.GetBoolValue("resource");
				NewHydro.prop = MarkerTable.GetStringValue("prop");

				NewHydro.color = MarkerTable.GetColorValue("color");

//.........这里部分代码省略.........
开发者ID:ozonexo3,项目名称:FAForeverMapEditor,代码行数:101,代码来源:MapLuaParser.cs

示例11: LoadRecipes

		public static void LoadRecipes()
		{
			using (Lua lua = new Lua())
			{
				List<String> luaFiles = getAllLuaFiles().ToList();
				List<String> luaDirs = getAllModDirs().ToList();

				//Add all these files to the Lua path variable
				foreach (String dir in luaDirs)
				{
					AddLuaPackagePath(lua, dir); //Prototype folder matches package hierarchy so this is enough.
				}

				AddLuaPackagePath(lua, Path.Combine(luaDirs[0], "lualib")); //Add lualib dir

				String dataloaderFile = luaFiles.Find(f => f.EndsWith("dataloader.lua"));
				String autoplaceFile = luaFiles.Find(f => f.EndsWith("autoplace_utils.lua"));

				List<String> itemFiles = luaFiles.Where(f => f.Contains("prototypes" + Path.DirectorySeparatorChar + "item")).ToList();
				itemFiles.AddRange(luaFiles.Where(f => f.Contains("prototypes" + Path.DirectorySeparatorChar + "fluid")).ToList());
				itemFiles.AddRange(luaFiles.Where(f => f.Contains("prototypes" + Path.DirectorySeparatorChar + "equipment")).ToList());
				List<String> recipeFiles = luaFiles.Where(f => f.Contains("prototypes" + Path.DirectorySeparatorChar + "recipe")).ToList();
				List<String> entityFiles = luaFiles.Where(f => f.Contains("prototypes" + Path.DirectorySeparatorChar + "entity")).ToList();
				
				try
				{
					lua.DoFile(dataloaderFile);
				}
				catch (Exception e)
				{
					failedFiles[dataloaderFile] = e;
					return; //There's no way to load anything else without this file.
				}
				try
				{
					lua.DoFile(autoplaceFile);
				}
				catch (Exception e)
				{
					failedFiles[autoplaceFile] = e;
				}
				foreach (String f in itemFiles.Union(recipeFiles).Union(entityFiles))
				{
					try
					{
						lua.DoFile(f);
					}
					catch (NLua.Exceptions.LuaScriptException e)
					{
						failedFiles[f] = e;
					}
				}

				foreach (String type in new List<String> { "item", "fluid", "capsule", "module", "ammo", "gun", "armor", "blueprint", "deconstruction-item" })
				{
					InterpretItems(lua, type);
				}

				LuaTable recipeTable = lua.GetTable("data.raw")["recipe"] as LuaTable;
				if (recipeTable != null)
				{
					var recipeEnumerator = recipeTable.GetEnumerator();
					while (recipeEnumerator.MoveNext())
					{
						InterpretLuaRecipe(recipeEnumerator.Key as String, recipeEnumerator.Value as LuaTable);
					}
				}

				LuaTable assemblerTable = lua.GetTable("data.raw")["assembling-machine"] as LuaTable;
				if (assemblerTable != null)
				{
					var assemblerEnumerator = assemblerTable.GetEnumerator();
					while (assemblerEnumerator.MoveNext())
					{
						InterpretAssemblingMachine(assemblerEnumerator.Key as String, assemblerEnumerator.Value as LuaTable);
					}
				}

				LuaTable furnaceTable = lua.GetTable("data.raw")["furnace"] as LuaTable;
				if (furnaceTable != null)
				{
					var furnaceEnumerator = furnaceTable.GetEnumerator();
					while (furnaceEnumerator.MoveNext())
					{
						InterpretFurnace(furnaceEnumerator.Key as String, furnaceEnumerator.Value as LuaTable);
					}
				}

				LuaTable minerTable = lua.GetTable("data.raw")["mining-drill"] as LuaTable;
				if (minerTable != null)
				{
					var minerEnumerator = minerTable.GetEnumerator();
					while (minerEnumerator.MoveNext())
					{
						InterpretMiner(minerEnumerator.Key as String, minerEnumerator.Value as LuaTable);
					}
				}

				LuaTable resourceTable = lua.GetTable("data.raw")["resource"] as LuaTable;
				if (resourceTable != null)
//.........这里部分代码省略.........
开发者ID:w-flo,项目名称:foreman-pkg,代码行数:101,代码来源:DataCache.cs

示例12: InterpretItems

		private static void InterpretItems(Lua lua, String typeName)
		{
			LuaTable itemTable = lua.GetTable("data.raw")[typeName] as LuaTable;

			if (itemTable != null)
			{
				var enumerator = itemTable.GetEnumerator();
				while (enumerator.MoveNext())
				{
					InterpretLuaItem(enumerator.Key as String, enumerator.Value as LuaTable);
				}
			}
		}
开发者ID:w-flo,项目名称:foreman-pkg,代码行数:13,代码来源:DataCache.cs


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