refactor
This commit is contained in:
parent
2c21b346f4
commit
94cc8a8069
9 changed files with 161 additions and 56 deletions
|
|
@ -1,8 +1,9 @@
|
||||||
---------------------------------------------------------------------------------------------------
|
---------------------------------------------------------------------------------------------------
|
||||||
Version: 0.7.4
|
Version: 0.7.4
|
||||||
Date: 2021-07-01
|
Date: 2021-07-26
|
||||||
Changes:
|
Changes:
|
||||||
- Very minor K2 tech tree tweak
|
- Very minor K2 tech tree tweak
|
||||||
|
- Minor Refactor
|
||||||
---------------------------------------------------------------------------------------------------
|
---------------------------------------------------------------------------------------------------
|
||||||
Version: 0.7.3
|
Version: 0.7.3
|
||||||
Date: 2021-07-01
|
Date: 2021-07-01
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ local util = require("__bzsilicon__.util");
|
||||||
|
|
||||||
-- Mod Mash Splinter Electronics
|
-- Mod Mash Splinter Electronics
|
||||||
if mods.modmashsplinterelectronics then
|
if mods.modmashsplinterelectronics then
|
||||||
if util.more_intermediates() then
|
if util.me.more_intermediates() then
|
||||||
util.multiply_recipe("advanced-circuit", 3)
|
util.multiply_recipe("advanced-circuit", 3)
|
||||||
util.add_ingredient("advanced-circuit", "silicon-wafer", 1)
|
util.add_ingredient("advanced-circuit", "silicon-wafer", 1)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ if deadlock then
|
||||||
if not mods["Krastorio2"] then
|
if not mods["Krastorio2"] then
|
||||||
deadlock.add_stack("silicon", "__bzsilicon__/graphics/icons/stacked/silicon-stacked.png" , "deadlock-stacking-2", 64)
|
deadlock.add_stack("silicon", "__bzsilicon__/graphics/icons/stacked/silicon-stacked.png" , "deadlock-stacking-2", 64)
|
||||||
end
|
end
|
||||||
if util.more_intermediates() then
|
if util.me.more_intermediates() then
|
||||||
deadlock.add_stack("silicon-wafer", "__bzsilicon__/graphics/icons/stacked/silicon-wafer-stacked.png" , "deadlock-stacking-2", 64)
|
deadlock.add_stack("silicon-wafer", "__bzsilicon__/graphics/icons/stacked/silicon-wafer-stacked.png" , "deadlock-stacking-2", 64)
|
||||||
deadlock.add_stack("solar-cell", "__bzsilicon__/graphics/icons/stacked/solar-cell-stacked.png" , "deadlock-stacking-2", 64)
|
deadlock.add_stack("solar-cell", "__bzsilicon__/graphics/icons/stacked/solar-cell-stacked.png" , "deadlock-stacking-2", 64)
|
||||||
end
|
end
|
||||||
|
|
@ -20,7 +20,7 @@ if deadlock_crating then
|
||||||
if not mods["Krastorio2"] then
|
if not mods["Krastorio2"] then
|
||||||
deadlock_crating.add_crate("silicon", "deadlock-crating-2")
|
deadlock_crating.add_crate("silicon", "deadlock-crating-2")
|
||||||
end
|
end
|
||||||
if util.more_intermediates() then
|
if util.me.more_intermediates() then
|
||||||
deadlock_crating.add_crate("silicon-wafer", "deadlock-crating-2", 64)
|
deadlock_crating.add_crate("silicon-wafer", "deadlock-crating-2", 64)
|
||||||
deadlock_crating.add_crate("solar-cell", "deadlock-crating-2", 64)
|
deadlock_crating.add_crate("solar-cell", "deadlock-crating-2", 64)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
28
me.lua
Normal file
28
me.lua
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
local me = {}
|
||||||
|
|
||||||
|
me.name = "bzsilicon"
|
||||||
|
me.silicon_processing = mods["Krastorio2"] and "kr-silicon-processing" or "silicon-processing"
|
||||||
|
|
||||||
|
function me.more_intermediates()
|
||||||
|
return mods["Bio_Industries"] or me.get_setting("bzsilicon-more-intermediates") == "yes"
|
||||||
|
end
|
||||||
|
|
||||||
|
function me.use_bio_crushed_stone()
|
||||||
|
return mods["Bio_Industries"] and me.get_setting("bzsilicon-bio-crushed-stone") == true
|
||||||
|
end
|
||||||
|
|
||||||
|
function me.get_setting(name)
|
||||||
|
if settings.startup[name] == nil then
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
return settings.startup[name].value
|
||||||
|
end
|
||||||
|
|
||||||
|
me.bypass = {}
|
||||||
|
if me.get_setting(me.name.."-recipe-bypass") then
|
||||||
|
for recipe in string.gmatch(me.get_setting(me.name.."-recipe-bypass"), '[^",%s]+') do
|
||||||
|
me.bypass[recipe] = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return me
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
local util = require("__bzsilicon__.util");
|
local util = require("__bzsilicon__.util");
|
||||||
|
|
||||||
recipes = {"silica", "silicon"}
|
recipes = {"silica", "silicon"}
|
||||||
if util.more_intermediates() then
|
if util.me.more_intermediates() then
|
||||||
table.insert(recipes, "silicon-wafer")
|
table.insert(recipes, "silicon-wafer")
|
||||||
table.insert(recipes, "solar-cell")
|
table.insert(recipes, "solar-cell")
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ data:extend(
|
||||||
ingredients = {{"quartz", 10}},
|
ingredients = {{"quartz", 10}},
|
||||||
result = "silica",
|
result = "silica",
|
||||||
result_count = 30
|
result_count = 30
|
||||||
} or util.use_bio_crushed_stone() and {
|
} or util.me.use_bio_crushed_stone() and {
|
||||||
type = "recipe",
|
type = "recipe",
|
||||||
name = "silica",
|
name = "silica",
|
||||||
category = "smelting",
|
category = "smelting",
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ data:extend(
|
||||||
type = "unlock-recipe",
|
type = "unlock-recipe",
|
||||||
recipe = "silicon",
|
recipe = "silicon",
|
||||||
},
|
},
|
||||||
util.more_intermediates() and
|
util.me.more_intermediates() and
|
||||||
{
|
{
|
||||||
type = "unlock-recipe",
|
type = "unlock-recipe",
|
||||||
recipe = "silicon-wafer",
|
recipe = "silicon-wafer",
|
||||||
|
|
@ -83,7 +83,7 @@ data:extend(
|
||||||
} or nil,
|
} or nil,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
if util.more_intermediates() then
|
if util.me.more_intermediates() then
|
||||||
data:extend({
|
data:extend({
|
||||||
{
|
{
|
||||||
type = "item",
|
type = "item",
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ if not mods["Krastorio2"] then
|
||||||
end
|
end
|
||||||
util.add_prerequisite("concrete", "silica-processing")
|
util.add_prerequisite("concrete", "silica-processing")
|
||||||
|
|
||||||
if util.more_intermediates() then
|
if util.me.more_intermediates() then
|
||||||
util.replace_some_ingredient("processing-unit", "electronic-circuit", 10, "silicon-wafer", 3)
|
util.replace_some_ingredient("processing-unit", "electronic-circuit", 10, "silicon-wafer", 3)
|
||||||
|
|
||||||
util.multiply_recipe("effectivity-module", 2)
|
util.multiply_recipe("effectivity-module", 2)
|
||||||
|
|
@ -35,7 +35,7 @@ if not mods["Krastorio2"] then
|
||||||
util.multiply_recipe("advanced-circuit", 3)
|
util.multiply_recipe("advanced-circuit", 3)
|
||||||
util.replace_some_ingredient("advanced-circuit", "electronic-circuit", 3, "silicon-wafer", 1)
|
util.replace_some_ingredient("advanced-circuit", "electronic-circuit", 3, "silicon-wafer", 1)
|
||||||
end
|
end
|
||||||
util.add_prerequisite("advanced-electronics", util.silicon_processing)
|
util.add_prerequisite("advanced-electronics", util.me.silicon_processing)
|
||||||
|
|
||||||
else
|
else
|
||||||
util.replace_some_ingredient("solar-panel", "electronic-circuit", 10, "silicon", 10)
|
util.replace_some_ingredient("solar-panel", "electronic-circuit", 10, "silicon", 10)
|
||||||
|
|
@ -49,11 +49,11 @@ if not mods["Krastorio2"] then
|
||||||
util.remove_ingredient("speed-module", "electronic-circuit")
|
util.remove_ingredient("speed-module", "electronic-circuit")
|
||||||
util.add_ingredient("speed-module", "silicon", 3)
|
util.add_ingredient("speed-module", "silicon", 3)
|
||||||
|
|
||||||
util.add_prerequisite("advanced-electronics-2", util.silicon_processing)
|
util.add_prerequisite("advanced-electronics-2", util.me.silicon_processing)
|
||||||
end
|
end
|
||||||
|
|
||||||
util.add_prerequisite("solar-energy", "silicon-processing")
|
util.add_prerequisite("solar-energy", "silicon-processing")
|
||||||
util.add_prerequisite("modules", util.silicon_processing)
|
util.add_prerequisite("modules", util.me.silicon_processing)
|
||||||
else
|
else
|
||||||
util.add_ingredient("concrete", "silica", 15);
|
util.add_ingredient("concrete", "silica", 15);
|
||||||
if not mods["aai-industry"] then
|
if not mods["aai-industry"] then
|
||||||
|
|
@ -127,16 +127,16 @@ util.replace_some_ingredient("transport-depot-writer", "electronic-circuit", 5,
|
||||||
|
|
||||||
|
|
||||||
util.add_prerequisite("circuit-network", "fiber-optics")
|
util.add_prerequisite("circuit-network", "fiber-optics")
|
||||||
util.add_prerequisite("circuit-network", util.silicon_processing)
|
util.add_prerequisite("circuit-network", util.me.silicon_processing)
|
||||||
|
|
||||||
if mods["Krastorio2"] then
|
if mods["Krastorio2"] then
|
||||||
util.add_ingredient("biusart-lab", "optical-fiber", 10)
|
util.add_ingredient("biusart-lab", "optical-fiber", 10)
|
||||||
util.add_ingredient("ai-core", "optical-fiber", 2)
|
util.add_ingredient("ai-core", "optical-fiber", 2)
|
||||||
|
|
||||||
util.add_prerequisite(util.silicon_processing, "silica-processing")
|
util.add_prerequisite(util.me.silicon_processing, "silica-processing")
|
||||||
|
|
||||||
if util.more_intermediates() then
|
if util.me.more_intermediates() then
|
||||||
util.add_effect(util.silicon_processing, {type = "unlock-recipe", recipe="silicon-wafer"})
|
util.add_effect(util.me.silicon_processing, {type = "unlock-recipe", recipe="silicon-wafer"})
|
||||||
util.remove_ingredient("electronic-components", "silicon")
|
util.remove_ingredient("electronic-components", "silicon")
|
||||||
util.add_ingredient("electronic-components", "silicon-wafer", 1)
|
util.add_ingredient("electronic-components", "silicon-wafer", 1)
|
||||||
|
|
||||||
|
|
@ -170,7 +170,7 @@ if mods["space-exploration"] then
|
||||||
end
|
end
|
||||||
|
|
||||||
if mods["zombiesextended-core"] then
|
if mods["zombiesextended-core"] then
|
||||||
if util.more_intermediates() then
|
if util.me.more_intermediates() then
|
||||||
util.add_ingredient("complex-processing-unit", "silicon-wafer", 1)
|
util.add_ingredient("complex-processing-unit", "silicon-wafer", 1)
|
||||||
else
|
else
|
||||||
util.add_ingredient("complex-processing-unit", "silicon", 2)
|
util.add_ingredient("complex-processing-unit", "silicon", 2)
|
||||||
|
|
|
||||||
154
util.lua
154
util.lua
|
|
@ -1,27 +1,12 @@
|
||||||
|
local me = require("me")
|
||||||
local util = {}
|
local util = {}
|
||||||
|
|
||||||
util.name = "bzsilicon"
|
util.me = me
|
||||||
util.silicon_processing = mods["Krastorio2"] and "kr-silicon-processing" or "silicon-processing"
|
util.get_setting = util.me.get_setting
|
||||||
|
|
||||||
function util.more_intermediates()
|
function util.fe_plus(sub)
|
||||||
return mods["Bio_Industries"] or util.get_setting("bzsilicon-more-intermediates") == "yes"
|
if mods["FactorioExtended-Plus-"..sub] then
|
||||||
end
|
return true
|
||||||
|
|
||||||
function util.use_bio_crushed_stone()
|
|
||||||
return mods["Bio_Industries"] and util.get_setting("bzsilicon-bio-crushed-stone") == true
|
|
||||||
end
|
|
||||||
|
|
||||||
function util.get_setting(name)
|
|
||||||
if settings.startup[name] == nil then
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
return settings.startup[name].value
|
|
||||||
end
|
|
||||||
|
|
||||||
local bypass = {}
|
|
||||||
if util.get_setting(util.name.."-recipe-bypass") then
|
|
||||||
for recipe in string.gmatch(util.get_setting(util.name.."-recipe-bypass"), '[^",%s]+') do
|
|
||||||
bypass[recipe] = true
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -90,8 +75,8 @@ end
|
||||||
|
|
||||||
-- Add a given quantity of ingredient to a given recipe
|
-- Add a given quantity of ingredient to a given recipe
|
||||||
function util.add_ingredient(recipe_name, ingredient, quantity)
|
function util.add_ingredient(recipe_name, ingredient, quantity)
|
||||||
if bypass[recipe_name] then return end
|
if me.bypass[recipe_name] then return end
|
||||||
if data.raw.recipe[recipe_name] then
|
if data.raw.recipe[recipe_name] and data.raw.item[ingredient] then
|
||||||
add_ingredient(data.raw.recipe[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].normal, ingredient, quantity)
|
||||||
add_ingredient(data.raw.recipe[recipe_name].expensive, ingredient, quantity)
|
add_ingredient(data.raw.recipe[recipe_name].expensive, ingredient, quantity)
|
||||||
|
|
@ -113,7 +98,7 @@ end
|
||||||
-- Add a given quantity of product to a given recipe.
|
-- Add a given quantity of product to a given recipe.
|
||||||
-- Only works for recipes with multiple products
|
-- Only works for recipes with multiple products
|
||||||
function util.add_product(recipe_name, product)
|
function util.add_product(recipe_name, product)
|
||||||
if data.raw.recipe[recipe_name] then
|
if data.raw.recipe[recipe_name] and data.raw.item[product] then
|
||||||
add_product(data.raw.recipe[recipe_name], product)
|
add_product(data.raw.recipe[recipe_name], product)
|
||||||
add_product(data.raw.recipe[recipe_name].normal, product)
|
add_product(data.raw.recipe[recipe_name].normal, product)
|
||||||
add_product(data.raw.recipe[recipe_name].expensive, product)
|
add_product(data.raw.recipe[recipe_name].expensive, product)
|
||||||
|
|
@ -128,8 +113,8 @@ end
|
||||||
|
|
||||||
-- Replace one ingredient with another in a recipe
|
-- Replace one ingredient with another in a recipe
|
||||||
function util.replace_ingredient(recipe_name, old, new)
|
function util.replace_ingredient(recipe_name, old, new)
|
||||||
if bypass[recipe_name] then return end
|
if me.bypass[recipe_name] then return end
|
||||||
if data.raw.recipe[recipe_name] then
|
if data.raw.recipe[recipe_name] and data.raw.item[new] then
|
||||||
replace_ingredient(data.raw.recipe[recipe_name], old, new)
|
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].normal, old, new)
|
||||||
replace_ingredient(data.raw.recipe[recipe_name].expensive, old, new)
|
replace_ingredient(data.raw.recipe[recipe_name].expensive, old, new)
|
||||||
|
|
@ -153,7 +138,7 @@ end
|
||||||
|
|
||||||
-- Remove an ingredient from a recipe
|
-- Remove an ingredient from a recipe
|
||||||
function util.remove_ingredient(recipe_name, old)
|
function util.remove_ingredient(recipe_name, old)
|
||||||
if bypass[recipe_name] then return end
|
if me.bypass[recipe_name] then return end
|
||||||
if data.raw.recipe[recipe_name] then
|
if data.raw.recipe[recipe_name] then
|
||||||
remove_ingredient(data.raw.recipe[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].normal, old)
|
||||||
|
|
@ -176,11 +161,10 @@ function remove_ingredient(recipe, old)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Replace an amount of an ingredient in a recipe. Keep at least 1 of old.
|
-- Replace an amount of an ingredient in a recipe. Keep at least 1 of old.
|
||||||
function util.replace_some_ingredient(recipe_name, old, old_amount, new, new_amount)
|
function util.replace_some_ingredient(recipe_name, old, old_amount, new, new_amount)
|
||||||
if bypass[recipe_name] then return end
|
if me.bypass[recipe_name] then return end
|
||||||
if data.raw.recipe[recipe_name] then
|
if data.raw.recipe[recipe_name] and data.raw.item[new] then
|
||||||
replace_some_ingredient(data.raw.recipe[recipe_name], old, old_amount, new, new_amount)
|
replace_some_ingredient(data.raw.recipe[recipe_name], old, old_amount, new, new_amount)
|
||||||
replace_some_ingredient(data.raw.recipe[recipe_name].normal, old, old_amount, new, new_amount)
|
replace_some_ingredient(data.raw.recipe[recipe_name].normal, old, old_amount, new, new_amount)
|
||||||
replace_some_ingredient(data.raw.recipe[recipe_name].expensive, old, old_amount, new, new_amount)
|
replace_some_ingredient(data.raw.recipe[recipe_name].expensive, old, old_amount, new, new_amount)
|
||||||
|
|
@ -196,11 +180,9 @@ function replace_some_ingredient(recipe, old, old_amount, new, new_amount)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
for i, ingredient in pairs(recipe.ingredients) do
|
for i, ingredient in pairs(recipe.ingredients) do
|
||||||
-- For final fixes
|
|
||||||
if ingredient.name == old then
|
if ingredient.name == old then
|
||||||
ingredient.amount = math.max(1, ingredient.amount - old_amount)
|
ingredient.amount = math.max(1, ingredient.amount - old_amount)
|
||||||
end
|
end
|
||||||
-- For updates
|
|
||||||
if ingredient[1] == old then
|
if ingredient[1] == old then
|
||||||
ingredient[2] = math.max(1, ingredient[2] - old_amount)
|
ingredient[2] = math.max(1, ingredient[2] - old_amount)
|
||||||
end
|
end
|
||||||
|
|
@ -211,7 +193,7 @@ end
|
||||||
|
|
||||||
-- multiply the cost, energy, and results of a recipe by a multiple
|
-- multiply the cost, energy, and results of a recipe by a multiple
|
||||||
function util.multiply_recipe(recipe_name, multiple)
|
function util.multiply_recipe(recipe_name, multiple)
|
||||||
if bypass[recipe_name] then return end
|
if me.bypass[recipe_name] then return end
|
||||||
if data.raw.recipe[recipe_name] then
|
if data.raw.recipe[recipe_name] then
|
||||||
multiply_recipe(data.raw.recipe[recipe_name], multiple)
|
multiply_recipe(data.raw.recipe[recipe_name], multiple)
|
||||||
multiply_recipe(data.raw.recipe[recipe_name].normal, multiple)
|
multiply_recipe(data.raw.recipe[recipe_name].normal, multiple)
|
||||||
|
|
@ -263,14 +245,108 @@ function multiply_recipe(recipe, multiple)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Remove an element of type t and name from data.raw
|
-- Returns true if a recipe has an ingredient
|
||||||
function util.remove_raw(t, name)
|
function util.has_ingredient(recipe_name, ingredient)
|
||||||
for i, elem in pairs(data.raw[t]) do
|
return data.raw.recipe[recipe_name] and (
|
||||||
if elem.name == name then
|
has_ingredient(data.raw.recipe[recipe_name], ingredient) or
|
||||||
data.raw[t][i] = nil
|
has_ingredient(data.raw.recipe[recipe_name].normal, ingredient))
|
||||||
break
|
end
|
||||||
|
|
||||||
|
function has_ingredient(recipe, ingredient)
|
||||||
|
if recipe ~= nil and recipe.ingredients ~= nil then
|
||||||
|
for i, existing in pairs(recipe.ingredients) do
|
||||||
|
if existing[1] == ingredient or existing.name == ingredient then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Replace one product with another in a recipe
|
||||||
|
function util.replace_product(recipe_name, old, new)
|
||||||
|
if data.raw.recipe[recipe_name] then
|
||||||
|
replace_product(data.raw.recipe[recipe_name], old, new)
|
||||||
|
replace_product(data.raw.recipe[recipe_name].normal, old, new)
|
||||||
|
replace_product(data.raw.recipe[recipe_name].expensive, old, new)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function replace_product(recipe, old, new)
|
||||||
|
if recipe ~= nil and recipe.results ~= nil then
|
||||||
|
if recipe.result == old then
|
||||||
|
recipe.results = new
|
||||||
|
return
|
||||||
|
end
|
||||||
|
for i, result in pairs(recipe.results) do
|
||||||
|
if result.name == old then result.name = new end
|
||||||
|
if result[1] == old then result[1] = new end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Remove an element of type t and name from data.raw
|
||||||
|
function util.remove_raw(t, name)
|
||||||
|
if data.raw[t][name] then
|
||||||
|
for i, elem in pairs(data.raw[t]) do
|
||||||
|
if elem.name == name then
|
||||||
|
data.raw[t][i] = nil
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Multiply energy required
|
||||||
|
function util.multiply_time(recipe, factor)
|
||||||
|
if me.bypass[recipe_name] then return end
|
||||||
|
if data.raw.recipe[recipe_name] then
|
||||||
|
multiply_time(data.raw.recipe[recipe_name], factor)
|
||||||
|
multiply_time(data.raw.recipe[recipe_name].normal, factor)
|
||||||
|
multiply_time(data.raw.recipe[recipe_name].expensive, factor)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function multiply_time(recipe, factor)
|
||||||
|
if recipe then
|
||||||
|
if recipe.energy_required then
|
||||||
|
recipe.energy_required = recipe.energy_required * factor
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Set recipe category
|
||||||
|
function util.set_category(recipe, category)
|
||||||
|
if me.bypass[recipe_name] then return end
|
||||||
|
if data.raw.recipe[recipe] then
|
||||||
|
data.raw.recipe[recipe].category = category
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Set recipe subgroup
|
||||||
|
function util.set_subgroup(recipe, subgroup)
|
||||||
|
if me.bypass[recipe_name] then return end
|
||||||
|
if data.raw.recipe[recipe] then
|
||||||
|
data.raw.recipe[recipe].subgroup = subgroup
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function util.set_to_founding(recipe)
|
||||||
|
util.set_category(recipe, "founding")
|
||||||
|
util.set_subgroup(recipe, "foundry-intermediate")
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Add crafting category to an entity
|
||||||
|
function util.add_crafting_category(entity_type, entity, category)
|
||||||
|
if data.raw[entity_type][entity] then
|
||||||
|
for i, existing in pairs(data.raw[entity_type][entity].crafting_categories) do
|
||||||
|
if existing == category then
|
||||||
|
log(entity.." not adding "..new.." -- duplicate")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
table.insert(data.raw[entity_type][entity].crafting_categories, category)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return util
|
return util
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue