fixed en locale and tech generate error

This commit is contained in:
Peter 2019-01-14 10:44:06 +08:00
parent 7a1ab68d68
commit 53020fe27c
6 changed files with 42 additions and 28 deletions

View File

@ -115,34 +115,40 @@ if settings.startup["017-techtree"].value then
local function compare(technology, science_pack, pre_tier) local function compare(technology, science_pack, pre_tier)
valid = true valid = true
for l, j in pairs(technology.unit.ingredients) do if technology and technology.unit then
if j[1] == pre_tier then for l, j in pairs(technology.unit.ingredients) do
valid = true if j[1] == pre_tier then
break valid = true
else break
valid = false else
valid = false
end
end end
end end
if valid == true then if valid == true then
if technology.prerequisites then if technology.prerequisites then
for _=1, #technology.prerequisites do for _=1, #technology.prerequisites do
local tech = data.raw["technology"][technology.prerequisites[_]] local tech = data.raw["technology"][technology.prerequisites[_]]
if tech.unit and valid == true then if valid == true then
for i, ingredients in pairs(tech.unit.ingredients) do if tech then
if ingredients[1] == pre_tier then if tech.unit then
valid = false 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 break
else
valid = true
end end
end end
elseif valid == false then
break
end end
end end
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 technology.prerequisites[#technology.prerequisites+1] = science_pack
return true return true
else else
@ -161,13 +167,13 @@ if settings.startup["017-techtree"].value then
end end
end end
if whitelisted == true then 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 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 if valid == false then
local valid = compare(tech, "production-science-pack", "production-science-pack") end local valid = compare(tech, "production-science-pack", "production-science-pack") end
if valid == false then 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 end
end end

View File

@ -1,6 +1,6 @@
{ {
"name": "017_science", "name": "017_science",
"version": "0.0.12", "version": "0.0.13",
"factorio_version": "0.16", "factorio_version": "0.16",
"title": "0.17 science conversion", "title": "0.17 science conversion",
"author": "npc_strider(morley376)", "author": "npc_strider(morley376)",

View File

@ -1,9 +1,9 @@
[technology-name] [technology-name]
belt-immunity-equipment=Belt immunity equipment belt-immunity-equipment=Belt immunity equipment
science-pack-2=Logistics science pack logistics-science-pack=Logistics science pack
science-pack-3=Chemical science pack chemical-science-pack=Chemical science pack
production-science-pack=Production science pack production-science-pack=Production science pack
high-tech-science-pack=Utility science pack utility-science-pack=Utility science pack
[item-name] [item-name]
science-pack-1=Automation science pack science-pack-1=Automation science pack

View File

@ -2,13 +2,13 @@ for i, force in pairs(game.forces) do
local get_input_count = force.item_production_statistics.get_input_count local get_input_count = force.item_production_statistics.get_input_count
if get_input_count("science-pack-2") > 0 then if get_input_count("science-pack-2") > 0 then
force.recipes["science-pack-2"].enabled = true 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")) -- game.print(force.name .. " | " .. "science-pack-2" .. " | " .. get_input_count("science-pack-2"))
end end
if get_input_count("science-pack-3") > 0 then if get_input_count("science-pack-3") > 0 then
force.recipes["science-pack-3"].enabled = true force.recipes["science-pack-3"].enabled = true
force.recipes["17-chemical-science-pack"].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")) -- game.print(force.name .. " | " .. "science-pack-3" .. " | " .. get_input_count("science-pack-3"))
end end
if get_input_count("production-science-pack") > 0 then 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 if get_input_count("high-tech-science-pack") > 0 then
force.recipes["high-tech-science-pack"].enabled = true force.recipes["high-tech-science-pack"].enabled = true
force.recipes["17-utility-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")) -- game.print(force.name .. " | " .. "high-tech-science-pack" .. " | " .. get_input_count("high-tech-science-pack"))
end end
end end

View File

@ -0,0 +1,8 @@
{
"technology":
[
["science-pack-2", "logistics-science-pack"],
["science-pack-3", "chemical-science-pack"],
["high-tech-science-pack", "utility-science-pack"]
]
}

View File

@ -3,7 +3,7 @@ data:extend(
{ {
{ {
type = "technology", type = "technology",
name = "science-pack-2", name = "logistics-science-pack",
icon_size = 128, icon_size = 128,
icon = "__017_science__/graphics/technology/green.png", icon = "__017_science__/graphics/technology/green.png",
effects = effects =
@ -26,7 +26,7 @@ data:extend(
}, },
{ {
type = "technology", type = "technology",
name = "science-pack-3", name = "chemical-science-pack",
icon_size = 128, icon_size = 128,
icon = "__017_science__/graphics/technology/blue.png", icon = "__017_science__/graphics/technology/blue.png",
effects = effects =
@ -71,7 +71,7 @@ data:extend(
}, },
{ {
type = "technology", type = "technology",
name = "high-tech-science-pack", name = "utility-science-pack",
icon_size = 128, icon_size = 128,
icon = "__017_science__/graphics/technology/yellow.png", icon = "__017_science__/graphics/technology/yellow.png",
effects = effects =