up
This commit is contained in:
parent
1c043f8864
commit
859a090051
1 changed files with 28 additions and 13 deletions
|
|
@ -137,21 +137,25 @@ function util.add_unlock(technology_name, recipe)
|
||||||
util.add_effect(technology_name, {type="unlock-recipe", recipe=recipe})
|
util.add_effect(technology_name, {type="unlock-recipe", recipe=recipe})
|
||||||
end
|
end
|
||||||
|
|
||||||
-- remove recipe unlock effect from a given technology
|
-- remove recipe unlock effect from a given technology, multiple times if necessary
|
||||||
function util.remove_recipe_effect(technology_name, recipe_name)
|
function util.remove_recipe_effect(technology_name, recipe_name)
|
||||||
local technology = data.raw.technology[technology_name]
|
local technology = data.raw.technology[technology_name]
|
||||||
local index = -1
|
local index = -1
|
||||||
if technology and technology.effects then
|
local cnt = 0
|
||||||
for i, effect in pairs(technology.effects) do
|
if technology and technology.effects then
|
||||||
if effect.type == "unlock-recipe" and effect.recipe == recipe_name then
|
for i, effect in pairs(technology.effects) do
|
||||||
index = i
|
if effect.type == "unlock-recipe" and effect.recipe == recipe_name then
|
||||||
break
|
index = i
|
||||||
end
|
cnt = cnt + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if index > -1 then
|
||||||
|
table.remove(technology.effects, index)
|
||||||
|
if cnt > 1 then -- not over yet, do it again
|
||||||
|
util.remove_recipe_effect(technology_name, recipe_name)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
if index > -1 then
|
|
||||||
table.remove(technology.effects, index)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Set technology ingredients
|
-- Set technology ingredients
|
||||||
|
|
@ -964,5 +968,16 @@ function replace_ingredients_prior_to(tech, old, new, multiplier)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function util.remove_all_recipe_effects(recipe_name)
|
||||||
|
for name, _ in pairs(data.raw.technology) do
|
||||||
|
util.remove_recipe_effect(name, recipe_name)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function util.add_unlock_force(technology_name, recipe)
|
||||||
|
util.set_enabled(recipe, false)
|
||||||
|
util.remove_all_recipe_effects(recipe)
|
||||||
|
util.add_unlock(technology_name, recipe)
|
||||||
|
end
|
||||||
|
|
||||||
return util
|
return util
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue