up
This commit is contained in:
parent
2d59a511b0
commit
a664e31a06
1 changed files with 39 additions and 14 deletions
|
@ -23,6 +23,12 @@ else
|
|||
util.titanium_processing = "titanium-processing"
|
||||
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)
|
||||
if settings.startup[name] == nil then
|
||||
return nil
|
||||
|
@ -137,21 +143,25 @@ function util.add_unlock(technology_name, recipe)
|
|||
util.add_effect(technology_name, {type="unlock-recipe", recipe=recipe})
|
||||
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)
|
||||
local technology = data.raw.technology[technology_name]
|
||||
local index = -1
|
||||
if technology and technology.effects then
|
||||
for i, effect in pairs(technology.effects) do
|
||||
if effect.type == "unlock-recipe" and effect.recipe == recipe_name then
|
||||
index = i
|
||||
break
|
||||
end
|
||||
local technology = data.raw.technology[technology_name]
|
||||
local index = -1
|
||||
local cnt = 0
|
||||
if technology and technology.effects then
|
||||
for i, effect in pairs(technology.effects) do
|
||||
if effect.type == "unlock-recipe" and effect.recipe == recipe_name then
|
||||
index = i
|
||||
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
|
||||
if index > -1 then
|
||||
table.remove(technology.effects, index)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Set technology ingredients
|
||||
|
@ -933,7 +943,11 @@ function util.replace_ingredients_prior_to(tech, old, new, multiplier)
|
|||
end
|
||||
util.remove_prior_unlocks(tech, old)
|
||||
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)
|
||||
end
|
||||
end
|
||||
|
@ -964,5 +978,16 @@ function replace_ingredients_prior_to(tech, old, new, multiplier)
|
|||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue