Merge pull request #47 from Amuxix/fix_k2_SE_248k
Fix incompatibility with k2 + SE + 248k
This commit is contained in:
commit
91b171692d
1 changed files with 14 additions and 4 deletions
|
@ -1,18 +1,28 @@
|
||||||
if settings.startup['overhaul_mode'].value then
|
if settings.startup['overhaul_mode'].value then
|
||||||
-- indent ignored
|
-- indent ignored
|
||||||
|
|
||||||
|
local function add_ingredient(ingredients, item, item_amount)
|
||||||
|
for _, ingredient in ipairs(ingredients) do
|
||||||
|
if ingredient.name == item then
|
||||||
|
ingredient.amount = math.max(ingredient.amount, item_amount)
|
||||||
|
return --leave early if we already found this ingredient
|
||||||
|
end
|
||||||
|
end
|
||||||
|
table.insert(ingredients, {type="item", name=item, amount=item_amount})
|
||||||
|
end
|
||||||
|
|
||||||
local function add_to_recipe(recipe, item, item_amount)
|
local function add_to_recipe(recipe, item, item_amount)
|
||||||
if not data.raw.recipe[recipe] then
|
if not data.raw.recipe[recipe] then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if data.raw.recipe[recipe].ingredients then
|
if data.raw.recipe[recipe].ingredients then
|
||||||
table.insert(data.raw.recipe[recipe].ingredients, {type="item", name=item, amount=item_amount})
|
add_ingredient(data.raw.recipe[recipe].ingredients, item, item_amount )
|
||||||
end
|
end
|
||||||
|
|
||||||
if data.raw.recipe[recipe].normal and data.raw.recipe[recipe].expensive then
|
if data.raw.recipe[recipe].normal and data.raw.recipe[recipe].expensive then
|
||||||
table.insert(data.raw.recipe[recipe].normal.ingredients, {type="item", name=item, amount=item_amount})
|
add_ingredient(data.raw.recipe[recipe].normal.ingredients, item, item_amount )
|
||||||
table.insert(data.raw.recipe[recipe].expensive.ingredients, {type="item", name=item, amount=item_amount})
|
add_ingredient(data.raw.recipe[recipe].expensive.ingredients, item, item_amount )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -24,7 +34,7 @@ local function add_to_recipes(table_in)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function change_table_index(table_in, structure)
|
local function change_table_index(table_in, structure)
|
||||||
|
|
||||||
local indexed_table = {}
|
local indexed_table = {}
|
||||||
|
|
||||||
for _,v in ipairs(table_in) do
|
for _,v in ipairs(table_in) do
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue