diff --git a/lignumis/prototypes/compatibility/k2so.lua b/lignumis/prototypes/compatibility/k2so.lua index 88637a9..ac1affb 100644 --- a/lignumis/prototypes/compatibility/k2so.lua +++ b/lignumis/prototypes/compatibility/k2so.lua @@ -2,6 +2,52 @@ local Technology = require("__cf-lib__/data/Technology") if not mods["Krastorio2-spaced-out"] then return end +local data_util = require("__Krastorio2-spaced-out__/data-util") + +data:extend({ + { + type = "tool", + name = "gold-tech-card", + localised_description = { "item-description.science-pack" }, + icon = Lignumis.graphics .. "technology/lig-gold-science-pack-tech.png", + icon_size = 128, + subgroup = "science-pack", + order = "b09[gold-tech-card]", + stack_size = 200, + weight = 1 * kg, + durability = 1, + durability_description_key = "description.science-pack-remaining-amount-key", + durability_description_value = "description.science-pack-remaining-amount-value", + default_import_location = "lignumis" + } +}) + +data_util.make_tech_card("gold-tech-card", { + { type = "item", name = "gold-plate", amount = 10 }, + { type = "item", name = "gold-cable", amount = 10 } +}) + +data:extend({ + { + type = "technology", + name = "gold-tech-card", + icon = Lignumis.graphics .. "technology/lig-gold-science-pack-tech.png", + icon_size = 128, + unit = { + time = 45, + count = 500, + ingredients = { + { "production-science-pack", 1 }, + { "utility-science-pack", 1 } + } + }, + prerequisites = { "gold-fluid-handling", "utility-science-pack" }, + effects = { + { type = "unlock-recipe", recipe = "gold-tech-card" } + } + } +}) + data.raw.recipe["burner-inserter"].ingredients = { { type = "item", name = "wooden-gear-wheel", amount = 1 }, { type = "item", name = "lumber", amount = 1 } @@ -41,4 +87,58 @@ if settings.startup["kr-realistic-weapons"].value then pistol_attack.ammo_category = nil table.insert(pistol_attack.ammo_categories, "bullet") data.raw.recipe["firearm-magazine"].enabled = false -end \ No newline at end of file +end + +if settings.startup["lignumis-technology-progression"].value + and settings.startup["lignumis-k2so-gold-tech-card"].value +then + for _, technology in pairs(data.raw.technology) do + 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 ingredient_name = ingredient[1] or ingredient.name + + if ingredient_name == "wood-science-pack" then + has_wood_pack = true + 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 + local ingredients = {} + + for _, ingredient in pairs(technology.unit.ingredients) do + local ingredient_name = ingredient[1] or ingredient.name + + 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 + + for _, lab in pairs(data.raw.lab) do + if lab.inputs and not table.contains(Lignumis.lab_blacklist, lab.name) and not table.contains(lab.inputs, "gold-tech-card") then + table.insert(lab.inputs, "gold-tech-card") + end + end +end