compatible with K2, SE
This commit is contained in:
parent
febdfcf058
commit
2f8d74c655
6 changed files with 143 additions and 28 deletions
38
util.lua
38
util.lua
|
|
@ -1,5 +1,25 @@
|
|||
local util = {}
|
||||
|
||||
util.silicon_processing = mods["Krastorio2"] and "kr-silicon-processing" or "silicon-processing"
|
||||
|
||||
function util.get_stack_size(default)
|
||||
if mods["Krastorio2"] then
|
||||
size = tonumber(krastorio.general.getSafeSettingValue("kr-stack-size"))
|
||||
return size or default
|
||||
end
|
||||
return default
|
||||
end
|
||||
|
||||
-- Remove an element of type t and name from data.raw
|
||||
function util.remove_raw(t, name)
|
||||
for i, elem in pairs(data.raw[t]) do
|
||||
if elem.name == name then
|
||||
data.raw[t][i] = nil
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Add a prerequisite to a given technology
|
||||
function util.add_prerequisite(technology_name, prerequisite)
|
||||
technology = data.raw.technology[technology_name]
|
||||
|
|
@ -8,9 +28,11 @@ end
|
|||
|
||||
-- Add a given quantity of ingredient to a given recipe
|
||||
function util.add_ingredient(recipe_name, ingredient, quantity)
|
||||
add_ingredient(data.raw.recipe[recipe_name], ingredient, quantity)
|
||||
add_ingredient(data.raw.recipe[recipe_name].normal, ingredient, quantity)
|
||||
add_ingredient(data.raw.recipe[recipe_name].expensive, ingredient, quantity)
|
||||
if data.raw.recipe[recipe_name] then
|
||||
add_ingredient(data.raw.recipe[recipe_name], ingredient, quantity)
|
||||
add_ingredient(data.raw.recipe[recipe_name].normal, ingredient, quantity)
|
||||
add_ingredient(data.raw.recipe[recipe_name].expensive, ingredient, quantity)
|
||||
end
|
||||
end
|
||||
|
||||
function add_ingredient(recipe, ingredient, quantity)
|
||||
|
|
@ -21,9 +43,11 @@ end
|
|||
|
||||
-- Replace one ingredien with another in a recipe
|
||||
function util.replace_ingredient(recipe_name, old, new)
|
||||
if data.raw.recipe[recipe_name] then
|
||||
replace_ingredient(data.raw.recipe[recipe_name], old, new)
|
||||
replace_ingredient(data.raw.recipe[recipe_name].normal, old, new)
|
||||
replace_ingredient(data.raw.recipe[recipe_name].expensive, old, new)
|
||||
end
|
||||
end
|
||||
|
||||
function replace_ingredient(recipe, old, new)
|
||||
|
|
@ -39,9 +63,11 @@ end
|
|||
|
||||
-- Remove an ingredient from a recipe
|
||||
function util.remove_ingredient(recipe_name, old)
|
||||
remove_ingredient(data.raw.recipe[recipe_name], old)
|
||||
remove_ingredient(data.raw.recipe[recipe_name].normal, old)
|
||||
remove_ingredient(data.raw.recipe[recipe_name].expensive, old)
|
||||
if data.raw.recipe[recipe_name] then
|
||||
remove_ingredient(data.raw.recipe[recipe_name], old)
|
||||
remove_ingredient(data.raw.recipe[recipe_name].normal, old)
|
||||
remove_ingredient(data.raw.recipe[recipe_name].expensive, old)
|
||||
end
|
||||
end
|
||||
|
||||
function remove_ingredient(recipe, old)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue