Enhance K2SO Compatibility with Gold Research Data and Gold Tech Cards #15

Open
Jiopaba wants to merge 8 commits from Jiopaba/lignumis:master into master
Showing only changes of commit a100862e87 - Show all commits

View file

@ -78,27 +78,9 @@ data:extend({
} }
}) })
data:extend({ Technology:new("kr-advanced-lab")
{ :addRecipe("gold-research-data")
type = "technology", :addRecipe("gold-tech-card")
name = "gold-tech-card",
icon = Lignumis.graphics .. "technology/lig-gold-science-pack-tech.png",
icon_size = 128,
unit = {
time = 45,
count = 500,
ingredients = {
{ "wood-science-pack", 1 },
{ "steam-science-pack", 1 }
}
},
prerequisites = { "gold-fluid-handling", "kr-advanced-lab" },
effects = {
{ type = "unlock-recipe", recipe = "gold-research-data" },
{ type = "unlock-recipe", recipe = "gold-tech-card" }
}
}
})
data.raw.recipe["burner-inserter"].ingredients = { data.raw.recipe["burner-inserter"].ingredients = {
{ type = "item", name = "wooden-gear-wheel", amount = 1 }, { type = "item", name = "wooden-gear-wheel", amount = 1 },
@ -141,89 +123,76 @@ if settings.startup["kr-realistic-weapons"].value then
data.raw.recipe["firearm-magazine"].enabled = false data.raw.recipe["firearm-magazine"].enabled = false
end end
if settings.startup["lignumis-technology-progression"].value if not (settings.startup["lignumis-technology-progression"].value and
and settings.startup["lignumis-k2so-gold-tech-card"].value settings.startup["lignumis-k2so-gold-tech-card"].value) then
then return
for _, technology in pairs(data.raw.technology) do end
if technology.unit
and technology.unit.ingredients
and not technology.lignumis_skip_science_packs
and not table.contains(Lignumis.science_blacklist, technology.name)
and not table.contains(Lignumis.science_pack_whitelist, technology.name)
then
local has_whitelisted_pack = false
local has_wood_pack = false
local has_steam_pack = false
for _, ingredient in pairs(technology.unit.ingredients) do local function upgrade_to_gold_card(tech)
local ingredient_name = ingredient[1] or ingredient.name if not (tech and tech.unit and tech.unit.ingredients) then return end
if ingredient_name == "wood-science-pack" then local new_ingredients = {}
has_wood_pack = true local changed = false
elseif ingredient_name == "steam-science-pack" then
has_steam_pack = true
elseif table.contains(Lignumis.science_pack_whitelist, ingredient_name) then
has_whitelisted_pack = true
end
end
if has_whitelisted_pack and has_wood_pack and has_steam_pack then for _, ing in pairs(tech.unit.ingredients) do
local ingredients = {} local name = ing[1] or ing.name
if name == "wood-science-pack" or name == "steam-science-pack" then
for _, ingredient in pairs(technology.unit.ingredients) do changed = true
local ingredient_name = ingredient[1] or ingredient.name else
table.insert(new_ingredients, ing)
if ingredient_name ~= "wood-science-pack" and ingredient_name ~= "steam-science-pack" then
table.insert(ingredients, ingredient)
end
end
table.insert(ingredients, { "gold-tech-card", 1 })
technology.unit.ingredients = ingredients
if technology.prerequisites and not table.contains(technology.prerequisites, "gold-tech-card") then
table.insert(technology.prerequisites, "gold-tech-card")
end
end
end end
end end
for _, lab in pairs(data.raw.lab) do local has_gold = false
if lab.inputs and not table.contains(Lignumis.lab_blacklist, lab.name) and not table.contains(lab.inputs, "gold-tech-card") then for _, ing in pairs(new_ingredients) do
table.insert(lab.inputs, "gold-tech-card") if (ing[1] or ing.name) == "gold-tech-card" then has_gold = true break end
end
end end
local utility_science = data.raw.technology["utility-science-pack"] if not has_gold then
if utility_science and utility_science.unit and utility_science.unit.ingredients then table.insert(new_ingredients, {"gold-tech-card", 1})
local ingredients = {} changed = true
end
for _, ingredient in pairs(utility_science.unit.ingredients) do if changed then
local ingredient_name = ingredient[1] or ingredient.name tech.unit.ingredients = new_ingredients
tech.prerequisites = tech.prerequisites or {}
if ingredient_name ~= "wood-science-pack" and ingredient_name ~= "steam-science-pack" then if not table.contains(tech.prerequisites, "kr-advanced-lab") then
table.insert(ingredients, ingredient) table.insert(tech.prerequisites, "kr-advanced-lab")
end end
end end
end
local has_gold_card = false
for _, ingredient in pairs(ingredients) do for name, tech in pairs(data.raw.technology) do
local ingredient_name = ingredient[1] or ingredient.name if tech.unit and tech.unit.ingredients
if ingredient_name == "gold-tech-card" then and not tech.lignumis_skip_science_packs
has_gold_card = true and not table.contains(Lignumis.science_blacklist, name)
break and not table.contains(Lignumis.science_pack_whitelist, name) then
end
end local has_wood = false
local has_steam = false
if not has_gold_card then local has_white = false
table.insert(ingredients, { "gold-tech-card", 1 }) for _, ing in pairs(tech.unit.ingredients) do
end local n = ing[1] or ing.name
if n == "wood-science-pack" then has_wood = true
utility_science.unit.ingredients = ingredients elseif n == "steam-science-pack" then has_steam = true
elseif table.contains(Lignumis.science_pack_whitelist, n) then has_white = true end
utility_science.prerequisites = utility_science.prerequisites or {} end
if not table.contains(utility_science.prerequisites, "gold-tech-card") then
table.insert(utility_science.prerequisites, "gold-tech-card") if has_wood and has_steam and has_white then
upgrade_to_gold_card(tech)
end
end
end
-- Special Cases needing fixing
upgrade_to_gold_card(data.raw.technology["production-science-pack"])
upgrade_to_gold_card(data.raw.technology["utility-science-pack"])
-- Make sure gold tech card is in the labs, same code as in vanilla-updates.lua
for _, lab in pairs(data.raw.lab) do
if lab.inputs and not table.contains(Lignumis.lab_blacklist, lab.name) then
if not table.contains(lab.inputs, "gold-tech-card") then
table.insert(lab.inputs, "gold-tech-card")
end end
end end
end end