This commit is contained in:
Brevven 2022-08-12 21:52:54 -07:00
parent 2d59a511b0
commit a664e31a06

View file

@ -23,6 +23,12 @@ else
util.titanium_processing = "titanium-processing" util.titanium_processing = "titanium-processing"
end end
function util.se6()
return mods["space-exploration"] and mods["space-exploration"] >= "0.6"
end
util.cablesg = util.se6() and "electronic" or "cable"
function get_setting(name) function get_setting(name)
if settings.startup[name] == nil then if settings.startup[name] == nil then
return nil return nil
@ -137,19 +143,23 @@ 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
local cnt = 0
if technology and technology.effects then if technology and technology.effects then
for i, effect in pairs(technology.effects) do for i, effect in pairs(technology.effects) do
if effect.type == "unlock-recipe" and effect.recipe == recipe_name then if effect.type == "unlock-recipe" and effect.recipe == recipe_name then
index = i index = i
break cnt = cnt + 1
end end
end end
if index > -1 then if index > -1 then
table.remove(technology.effects, index) 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 end
end end
@ -933,7 +943,11 @@ function util.replace_ingredients_prior_to(tech, old, new, multiplier)
end end
util.remove_prior_unlocks(tech, old) util.remove_prior_unlocks(tech, old)
for i, recipe in pairs(data.raw.recipe) do for i, recipe in pairs(data.raw.recipe) do
if recipe.enabled and recipe.enabled ~= 'false' then if (recipe.enabled and recipe.enabled ~= 'false')
and (not recipe.hidden or recipe.hidden == 'true') -- probably don't want to change hidden recipes
and string.sub(recipe.name, 1, 3) ~= 'se-' -- have to exlude SE in general :(
then
-- log("BZZZ due to 'enabled' replacing " .. old .. " with " .. new .." in " .. recipe.name)
util.replace_ingredient(recipe.name, old, new, multiplier, true) util.replace_ingredient(recipe.name, old, new, multiplier, true)
end end
end end
@ -964,5 +978,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