Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove trigger technologies and fix technology tree #445

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions data-util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,20 @@ function data_util.add_effect(technology_name, new_effect)
end
end

-- Remove the technology entirely
function data_util.remove_technology(technology_name)
data.raw.technology[technology_name] = nil
end

-- Remove research trigger from technology
function data_util.remove_research_trigger(technology_name)
local technology = data.raw.technology[technology_name]
if not technology then
error("Technology " .. technology_name .. " does not exist.")
end
technology.research_trigger = nil
end

--- Adds the given recipe as an unlock of the given technology.
--- @param technology_name data.TechnologyID
--- @param recipe_name data.RecipeID
Expand Down Expand Up @@ -214,6 +228,27 @@ function data_util.convert_research_unit_ingredient(technology_id, from_id, to_i
end
end

--- Adds research unit to the technology.
--- @param technology_id data.TechnologyID
--- @param count integer
--- @param time number
function data_util.add_research_unit(technology_id, count, time)
local technology = data.raw.technology[technology_id]
if not technology then
error("Technology " .. technology_id .. " does not exist.")
end

if technology.unit then
error("Technology " .. technology_id .. "already has a research unit")
end

technology.unit = {
count = count,
time = time,
ingredients = {}
}
end

--- Adds the given research ingredient to the technology.
--- @param technology_id data.TechnologyID
--- @param ingredient_id data.ItemID
Expand Down Expand Up @@ -408,6 +443,7 @@ function data_util.convert_ingredient(recipe_name, old_ingredient_name, new_ingr
end
end


--- Remove the given ingredient from the recipe.
--- @param recipe_name data.RecipeID
--- @param ingredient_name data.FluidID|data.ItemID
Expand Down
26 changes: 26 additions & 0 deletions prototypes/updates/base/recipes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ data_util.add_or_replace_ingredient(
"iron-plate",
{ type = "item", name = "iron-beam", amount = 4 }
)
data_util.add_or_replace_ingredient(
"assembling-machine-1",
"electronic-circuit",
Copy link
Contributor Author

@ukarlsson ukarlsson Dec 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw now that there is some code in prototypes/updates/add-automation-core-recipes.lua but it seems like it does not trigger and that is why it broke for multiple recipes, I suppose I could try to figure out what is wrong. It seems to be the same issue for

  • assembling-machine-1
  • electric-mining-drill
  • splitter

{ type = "item", name = "automation-core", amount = 2 }
)

data.raw.recipe["assembling-machine-2"].energy_required = 2

Expand Down Expand Up @@ -137,6 +142,14 @@ data_util.add_or_replace_ingredient(
{ type = "item", name = "iron-beam", amount = 2 }
)

data_util.add_or_replace_ingredient(
"electric-mining-drill",
"electronic-circuit",
{ type = "item", name = "automation-core", amount = 2 }
)

data.raw.recipe["copper-cable"].enabled = true

data.raw.recipe["electronic-circuit"].enabled = false
data.raw.recipe["electronic-circuit"].energy_required = 2
table.insert(data.raw.recipe["electronic-circuit"].ingredients, { type = "item", name = "wood", amount = 1 })
Expand Down Expand Up @@ -257,6 +270,8 @@ data.raw.recipe["inserter"].ingredients = {

data_util.add_or_replace_ingredient("iron-plate", "iron-ore", { type = "item", name = "iron-ore", amount = 2 })

data.raw.recipe["iron-stick"].enabled = true

data_util.add_or_replace_ingredient("iron-gear-wheel", "iron-plate", { type = "item", name = "iron-plate", amount = 1 })
data.raw.recipe["iron-gear-wheel"].results = { { type = "item", name = "iron-gear-wheel", amount = 1 } }

Expand All @@ -282,6 +297,8 @@ data_util.add_or_replace_product(
{ type = "item", name = "stone", amount = 2 }
)

data.raw.recipe["lab"].enabled = true

data_util.add_or_replace_ingredient("lab", "electronic-circuit", { type = "item", name = "iron-beam", amount = 10 })
data_util.add_or_replace_ingredient("lab", "iron-gear-wheel", { type = "item", name = "copper-plate", amount = 10 })
data_util.add_or_replace_ingredient("lab", "transport-belt", { type = "item", name = "copper-cable", amount = 10 })
Expand Down Expand Up @@ -392,6 +409,9 @@ data.raw.recipe["pipe"].enabled = false

data.raw.recipe["pipe-to-ground"].enabled = false

data.raw.recipe["pistol"].enabled = true
data.raw.recipe["pistol"].hidden = false

data_util.add_or_replace_ingredient("pistol", "iron-plate", { type = "item", name = "iron-plate", amount = 2 })
data_util.add_or_replace_ingredient("pistol", "copper-plate", { type = "item", name = "copper-plate", amount = 1 })

Expand Down Expand Up @@ -481,6 +501,8 @@ data_util.add_or_replace_ingredient(
)
data_util.remove_ingredient("refined-concrete", "iron-stick")

data.raw.recipe["repair-pack"].enabled = true

data_util.add_or_replace_ingredient(
"repair-pack",
"iron-gear-wheel",
Expand Down Expand Up @@ -518,6 +540,8 @@ data_util.add_or_replace_ingredient(

data_util.remove_ingredient("slowdown-capsule", "electronic-circuit")

data.raw.recipe["small-electric-pole"].enabled = true

data_util.add_or_replace_ingredient(
"small-electric-pole",
"copper-cable",
Expand Down Expand Up @@ -571,6 +595,8 @@ data_util.add_or_replace_ingredient(
)
data_util.convert_ingredient("spidertron", "raw-fish", "ai-core")

data_util.remove_ingredient("splitter", "electronic-circuit")

data_util.add_or_replace_ingredient("splitter", "iron-plate", { type = "item", name = "iron-gear-wheel", amount = 5 })
data_util.add_or_replace_ingredient(
"splitter",
Expand Down
26 changes: 26 additions & 0 deletions prototypes/updates/base/technologies.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
local data_util = require("data-util")

data_util.remove_technology("steam-power")
data_util.remove_technology("repair-pack")
data_util.remove_technology("electric-mining-drill")

data_util.remove_research_trigger("steel-axe")
data_util.remove_research_trigger("electronics")
data_util.remove_research_trigger("oil-processing")

data_util.add_research_unit("steel-axe", 50, 30)
data_util.add_research_unit_ingredient("steel-axe", "automation-science-pack")
data_util.add_research_unit("electronics", 30, 15)
data_util.add_research_unit_ingredient("electronics", "automation-science-pack")
data_util.add_research_unit("oil-processing", 100, 30)
data_util.add_research_unit_ingredient("oil-processing", "automation-science-pack")
data_util.add_research_unit_ingredient("oil-processing", "logistic-science-pack")

data_util.add_prerequisite("advanced-circuit", "electronics")
data_util.add_prerequisite("advanced-circuit", "kr-silicon-processing")
data_util.add_prerequisite("atomic-bomb", "kr-military-5")
Expand Down Expand Up @@ -88,6 +104,16 @@ if settings.startup["kr-loaders"].value then
data_util.add_recipe_unlock("logistics-3", "kr-express-loader")
end

data_util.remove_recipe_unlock("electronics", "lab")
data_util.remove_recipe_unlock("electronics", "copper-cable")
data_util.remove_recipe_unlock("electronics", "inserter")
data_util.remove_recipe_unlock("electronics", "small-electric-pole")

data_util.remove_recipe_unlock("electric-energy-distribution-1", "iron-stick")
data_util.remove_recipe_unlock("concrete", "iron-stick")
data_util.remove_recipe_unlock("railway", "iron-stick")
data_util.remove_recipe_unlock("circuit-network", "iron-stick")

data_util.remove_recipe_unlock("automation", "long-handed-inserter")
data_util.remove_recipe_unlock("kovarex-enrichment-process", "nuclear-fuel")
data_util.remove_recipe_unlock("military-3", "slowdown-capsule")
Expand Down