From 53020fe27cac36c8f37460b8d00a98bd23593c79 Mon Sep 17 00:00:00 2001 From: Peter Date: Mon, 14 Jan 2019 10:44:06 +0800 Subject: [PATCH] fixed en locale and tech generate error --- 017_science/data-updates.lua | 42 +++++++++++-------- 017_science/info.json | 2 +- 017_science/locale/en/base.cfg | 6 +-- .../2019-01-13_017_science_0.0.12.lua | 6 +-- .../2019-01-14_017_science_0.0.13.json | 8 ++++ 017_science/technology.lua | 6 +-- 6 files changed, 42 insertions(+), 28 deletions(-) create mode 100644 017_science/migrations/2019-01-14_017_science_0.0.13.json diff --git a/017_science/data-updates.lua b/017_science/data-updates.lua index 6d5b9db..5b6bd63 100644 --- a/017_science/data-updates.lua +++ b/017_science/data-updates.lua @@ -115,34 +115,40 @@ if settings.startup["017-techtree"].value then local function compare(technology, science_pack, pre_tier) valid = true - for l, j in pairs(technology.unit.ingredients) do - if j[1] == pre_tier then - valid = true - break - else - valid = false + if technology and technology.unit then + for l, j in pairs(technology.unit.ingredients) do + if j[1] == pre_tier then + valid = true + break + else + valid = false + end end end if valid == true then if technology.prerequisites then for _=1, #technology.prerequisites do local tech = data.raw["technology"][technology.prerequisites[_]] - if tech.unit and valid == true then - for i, ingredients in pairs(tech.unit.ingredients) do - if ingredients[1] == pre_tier then - valid = false + if valid == true then + if tech then + if tech.unit then + for i, ingredients in pairs(tech.unit.ingredients) do + if ingredients[1] == pre_tier then + valid = false + break + else + valid = true + end + end + elseif valid == false then break - else - valid = true end end - elseif valid == false then - break end end end end - if valid == true and technology.prerequisites then + if technology.prerequisites and valid == true then technology.prerequisites[#technology.prerequisites+1] = science_pack return true else @@ -161,13 +167,13 @@ if settings.startup["017-techtree"].value then end end if whitelisted == true then - local valid = compare(tech, "science-pack-2", "science-pack-2") + local valid = compare(tech, "logistics-science-pack", "science-pack-2") if valid == false then - local valid = compare(tech, "science-pack-3", "science-pack-3") end + local valid = compare(tech, "chemical-science-pack", "science-pack-3") end if valid == false then local valid = compare(tech, "production-science-pack", "production-science-pack") end if valid == false then - local valid = compare(tech, "high-tech-science-pack", "high-tech-science-pack") end + local valid = compare(tech, "utility-science-pack", "high-tech-science-pack") end end end end diff --git a/017_science/info.json b/017_science/info.json index a3ce5a5..e5d97b4 100644 --- a/017_science/info.json +++ b/017_science/info.json @@ -1,6 +1,6 @@ { "name": "017_science", - "version": "0.0.12", + "version": "0.0.13", "factorio_version": "0.16", "title": "0.17 science conversion", "author": "npc_strider(morley376)", diff --git a/017_science/locale/en/base.cfg b/017_science/locale/en/base.cfg index 6831f3a..1a5151f 100644 --- a/017_science/locale/en/base.cfg +++ b/017_science/locale/en/base.cfg @@ -1,9 +1,9 @@ [technology-name] belt-immunity-equipment=Belt immunity equipment -science-pack-2=Logistics science pack -science-pack-3=Chemical science pack +logistics-science-pack=Logistics science pack +chemical-science-pack=Chemical science pack production-science-pack=Production science pack -high-tech-science-pack=Utility science pack +utility-science-pack=Utility science pack [item-name] science-pack-1=Automation science pack diff --git a/017_science/migrations/2019-01-13_017_science_0.0.12.lua b/017_science/migrations/2019-01-13_017_science_0.0.12.lua index 6c4c0fd..70ba959 100644 --- a/017_science/migrations/2019-01-13_017_science_0.0.12.lua +++ b/017_science/migrations/2019-01-13_017_science_0.0.12.lua @@ -2,13 +2,13 @@ for i, force in pairs(game.forces) do local get_input_count = force.item_production_statistics.get_input_count if get_input_count("science-pack-2") > 0 then force.recipes["science-pack-2"].enabled = true - force.technologies["science-pack-2"].researched = true + force.technologies["logistics-science-pack"].researched = true -- game.print(force.name .. " | " .. "science-pack-2" .. " | " .. get_input_count("science-pack-2")) end if get_input_count("science-pack-3") > 0 then force.recipes["science-pack-3"].enabled = true force.recipes["17-chemical-science-pack"].enabled = true - force.technologies["science-pack-3"].researched = true + force.technologies["chemical-science-pack"].researched = true -- game.print(force.name .. " | " .. "science-pack-3" .. " | " .. get_input_count("science-pack-3")) end if get_input_count("production-science-pack") > 0 then @@ -20,7 +20,7 @@ for i, force in pairs(game.forces) do if get_input_count("high-tech-science-pack") > 0 then force.recipes["high-tech-science-pack"].enabled = true force.recipes["17-utility-science-pack"].enabled = true - force.technologies["high-tech-science-pack"].researched = true + force.technologies["utility-science-pack"].researched = true -- game.print(force.name .. " | " .. "high-tech-science-pack" .. " | " .. get_input_count("high-tech-science-pack")) end end \ No newline at end of file diff --git a/017_science/migrations/2019-01-14_017_science_0.0.13.json b/017_science/migrations/2019-01-14_017_science_0.0.13.json new file mode 100644 index 0000000..26dbca5 --- /dev/null +++ b/017_science/migrations/2019-01-14_017_science_0.0.13.json @@ -0,0 +1,8 @@ +{ + "technology": + [ + ["science-pack-2", "logistics-science-pack"], + ["science-pack-3", "chemical-science-pack"], + ["high-tech-science-pack", "utility-science-pack"] + ] +} \ No newline at end of file diff --git a/017_science/technology.lua b/017_science/technology.lua index e0c6f51..9b53b86 100644 --- a/017_science/technology.lua +++ b/017_science/technology.lua @@ -3,7 +3,7 @@ data:extend( { { type = "technology", - name = "science-pack-2", + name = "logistics-science-pack", icon_size = 128, icon = "__017_science__/graphics/technology/green.png", effects = @@ -26,7 +26,7 @@ data:extend( }, { type = "technology", - name = "science-pack-3", + name = "chemical-science-pack", icon_size = 128, icon = "__017_science__/graphics/technology/blue.png", effects = @@ -71,7 +71,7 @@ data:extend( }, { type = "technology", - name = "high-tech-science-pack", + name = "utility-science-pack", icon_size = 128, icon = "__017_science__/graphics/technology/yellow.png", effects =