advanced mod settings
This commit is contained in:
parent
e63d66ffae
commit
2aed15749e
4 changed files with 50 additions and 18 deletions
|
|
@ -1,4 +1,9 @@
|
||||||
---------------------------------------------------------------------------------------------------
|
---------------------------------------------------------------------------------------------------
|
||||||
|
Version: 0.11.3
|
||||||
|
Date: 2022-08-09
|
||||||
|
Changes:
|
||||||
|
- Support advanced optional settings
|
||||||
|
---------------------------------------------------------------------------------------------------
|
||||||
Version: 0.11.2
|
Version: 0.11.2
|
||||||
Date: 2022-07-02
|
Date: 2022-07-02
|
||||||
Fixes:
|
Fixes:
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,27 @@ else
|
||||||
util.titanium_processing = "titanium-processing"
|
util.titanium_processing = "titanium-processing"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function get_setting(name)
|
||||||
|
if settings.startup[name] == nil then
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
return settings.startup[name].value
|
||||||
|
end
|
||||||
|
|
||||||
|
allbypass = {}
|
||||||
|
if get_setting("bz-recipe-bypass") then
|
||||||
|
for recipe in string.gmatch(me.get_setting("bz-recipe-bypass"), '[^",%s]+') do
|
||||||
|
allbypass[recipe] = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function bypass(recipe_name)
|
||||||
|
if me.bypass[recipe_name] then return true end
|
||||||
|
if allbypass[recipe_name] then return true end
|
||||||
|
if get_setting("bz-tabula-rasa") then return true end
|
||||||
|
end
|
||||||
|
|
||||||
function util.fe_plus(sub)
|
function util.fe_plus(sub)
|
||||||
if mods["FactorioExtended-Plus-"..sub] then
|
if mods["FactorioExtended-Plus-"..sub] then
|
||||||
return true
|
return true
|
||||||
|
|
@ -159,7 +180,7 @@ end
|
||||||
|
|
||||||
-- Add a given quantity of ingredient to a given recipe
|
-- Add a given quantity of ingredient to a given recipe
|
||||||
function util.add_or_add_to_ingredient(recipe_name, ingredient, quantity)
|
function util.add_or_add_to_ingredient(recipe_name, ingredient, quantity)
|
||||||
if me.bypass[recipe_name] then return end
|
if bypass(recipe_name) then return end
|
||||||
if data.raw.recipe[recipe_name] and data.raw.item[ingredient] then
|
if data.raw.recipe[recipe_name] and data.raw.item[ingredient] then
|
||||||
me.add_modified(recipe_name)
|
me.add_modified(recipe_name)
|
||||||
add_or_add_to_ingredient(data.raw.recipe[recipe_name], ingredient, quantity)
|
add_or_add_to_ingredient(data.raw.recipe[recipe_name], ingredient, quantity)
|
||||||
|
|
@ -182,7 +203,7 @@ 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 me.bypass[recipe_name] then return end
|
if bypass(recipe_name) then return end
|
||||||
local is_fluid = not not data.raw.fluid[ingredient]
|
local is_fluid = not not data.raw.fluid[ingredient]
|
||||||
if data.raw.recipe[recipe_name] and (data.raw.item[ingredient] or is_fluid) then
|
if data.raw.recipe[recipe_name] and (data.raw.item[ingredient] or is_fluid) then
|
||||||
me.add_modified(recipe_name)
|
me.add_modified(recipe_name)
|
||||||
|
|
@ -209,7 +230,7 @@ end
|
||||||
|
|
||||||
-- Add a given ingredient prototype to a given recipe
|
-- Add a given ingredient prototype to a given recipe
|
||||||
function util.add_ingredient_raw(recipe_name, ingredient)
|
function util.add_ingredient_raw(recipe_name, ingredient)
|
||||||
if me.bypass[recipe_name] then return end
|
if bypass(recipe_name) then return end
|
||||||
if data.raw.recipe[recipe_name] and (data.raw.item[ingredient.name] or data.raw.item[ingredient[1]]) then
|
if data.raw.recipe[recipe_name] and (data.raw.item[ingredient.name] or data.raw.item[ingredient[1]]) then
|
||||||
me.add_modified(recipe_name)
|
me.add_modified(recipe_name)
|
||||||
add_ingredient_raw(data.raw.recipe[recipe_name], ingredient)
|
add_ingredient_raw(data.raw.recipe[recipe_name], ingredient)
|
||||||
|
|
@ -234,7 +255,7 @@ end
|
||||||
|
|
||||||
-- Set an ingredient to a given quantity
|
-- Set an ingredient to a given quantity
|
||||||
function util.set_ingredient(recipe_name, ingredient, quantity)
|
function util.set_ingredient(recipe_name, ingredient, quantity)
|
||||||
if me.bypass[recipe_name] then return end
|
if bypass(recipe_name) then return end
|
||||||
if data.raw.recipe[recipe_name] and data.raw.item[ingredient] then
|
if data.raw.recipe[recipe_name] and data.raw.item[ingredient] then
|
||||||
me.add_modified(recipe_name)
|
me.add_modified(recipe_name)
|
||||||
set_ingredient(data.raw.recipe[recipe_name], ingredient, quantity)
|
set_ingredient(data.raw.recipe[recipe_name], ingredient, quantity)
|
||||||
|
|
@ -262,6 +283,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 bypass(recipe_name) then return end
|
||||||
if data.raw.recipe[recipe_name] and (data.raw.item[product[1]] or data.raw.item[product.name]) then
|
if data.raw.recipe[recipe_name] and (data.raw.item[product[1]] or data.raw.item[product.name]) 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)
|
||||||
|
|
@ -329,7 +351,7 @@ 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, amount)
|
function util.replace_ingredient(recipe_name, old, new, amount)
|
||||||
if me.bypass[recipe_name] then return end
|
if bypass(recipe_name) then return end
|
||||||
if data.raw.recipe[recipe_name] and (data.raw.item[new] or data.raw.fluid[new]) then
|
if data.raw.recipe[recipe_name] and (data.raw.item[new] or data.raw.fluid[new]) then
|
||||||
me.add_modified(recipe_name)
|
me.add_modified(recipe_name)
|
||||||
replace_ingredient(data.raw.recipe[recipe_name], old, new, amount)
|
replace_ingredient(data.raw.recipe[recipe_name], old, new, amount)
|
||||||
|
|
@ -360,7 +382,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 me.bypass[recipe_name] then return end
|
if bypass(recipe_name) then return end
|
||||||
if data.raw.recipe[recipe_name] then
|
if data.raw.recipe[recipe_name] then
|
||||||
me.add_modified(recipe_name)
|
me.add_modified(recipe_name)
|
||||||
remove_ingredient(data.raw.recipe[recipe_name], old)
|
remove_ingredient(data.raw.recipe[recipe_name], old)
|
||||||
|
|
@ -386,7 +408,7 @@ 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 me.bypass[recipe_name] then return end
|
if bypass(recipe_name) then return end
|
||||||
local is_fluid = not not data.raw.fluid[new]
|
local is_fluid = not not data.raw.fluid[new]
|
||||||
if data.raw.recipe[recipe_name] and (data.raw.item[new] or is_fluid) then
|
if data.raw.recipe[recipe_name] and (data.raw.item[new] or is_fluid) then
|
||||||
me.add_modified(recipe_name)
|
me.add_modified(recipe_name)
|
||||||
|
|
@ -419,7 +441,7 @@ end
|
||||||
function util.set_product_amount(recipe_name, product, amount)
|
function util.set_product_amount(recipe_name, product, amount)
|
||||||
me.add_modified(recipe_name)
|
me.add_modified(recipe_name)
|
||||||
if data.raw.recipe[recipe_name] then
|
if data.raw.recipe[recipe_name] then
|
||||||
if me.bypass[recipe_name] then return end
|
if bypass(recipe_name) then return end
|
||||||
set_product_amount(data.raw.recipe[recipe_name], product, amount)
|
set_product_amount(data.raw.recipe[recipe_name], product, amount)
|
||||||
set_product_amount(data.raw.recipe[recipe_name].normal, product, amount)
|
set_product_amount(data.raw.recipe[recipe_name].normal, product, amount)
|
||||||
set_product_amount(data.raw.recipe[recipe_name].expensive, product, amount)
|
set_product_amount(data.raw.recipe[recipe_name].expensive, product, amount)
|
||||||
|
|
@ -459,7 +481,7 @@ end
|
||||||
function util.multiply_recipe(recipe_name, multiple)
|
function util.multiply_recipe(recipe_name, multiple)
|
||||||
me.add_modified(recipe_name)
|
me.add_modified(recipe_name)
|
||||||
if data.raw.recipe[recipe_name] then
|
if data.raw.recipe[recipe_name] then
|
||||||
if me.bypass[recipe_name] then return end
|
if bypass(recipe_name) then return end
|
||||||
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)
|
||||||
multiply_recipe(data.raw.recipe[recipe_name].expensive, multiple)
|
multiply_recipe(data.raw.recipe[recipe_name].expensive, multiple)
|
||||||
|
|
@ -532,7 +554,7 @@ end
|
||||||
function util.remove_product(recipe_name, old)
|
function util.remove_product(recipe_name, old)
|
||||||
me.add_modified(recipe_name)
|
me.add_modified(recipe_name)
|
||||||
if data.raw.recipe[recipe_name] then
|
if data.raw.recipe[recipe_name] then
|
||||||
if me.bypass[recipe_name] then return end
|
if bypass(recipe_name) then return end
|
||||||
remove_product(data.raw.recipe[recipe_name], old)
|
remove_product(data.raw.recipe[recipe_name], old)
|
||||||
remove_product(data.raw.recipe[recipe_name].normal, old)
|
remove_product(data.raw.recipe[recipe_name].normal, old)
|
||||||
remove_product(data.raw.recipe[recipe_name].expensive, old)
|
remove_product(data.raw.recipe[recipe_name].expensive, old)
|
||||||
|
|
@ -555,6 +577,7 @@ function remove_product(recipe, old)
|
||||||
end
|
end
|
||||||
|
|
||||||
function util.set_main_product(recipe_name, product)
|
function util.set_main_product(recipe_name, product)
|
||||||
|
if bypass(recipe_name) then return end
|
||||||
if data.raw.recipe[recipe_name] then
|
if data.raw.recipe[recipe_name] then
|
||||||
set_main_product(data.raw.recipe[recipe_name], product)
|
set_main_product(data.raw.recipe[recipe_name], product)
|
||||||
set_main_product(data.raw.recipe[recipe_name].normal, product)
|
set_main_product(data.raw.recipe[recipe_name].normal, product)
|
||||||
|
|
@ -570,6 +593,7 @@ end
|
||||||
|
|
||||||
-- Replace one product with another in a recipe
|
-- Replace one product with another in a recipe
|
||||||
function util.replace_product(recipe_name, old, new)
|
function util.replace_product(recipe_name, old, new)
|
||||||
|
if bypass(recipe_name) then return end
|
||||||
if data.raw.recipe[recipe_name] then
|
if data.raw.recipe[recipe_name] then
|
||||||
replace_product(data.raw.recipe[recipe_name], old, new)
|
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].normal, old, new)
|
||||||
|
|
@ -615,7 +639,7 @@ end
|
||||||
function util.set_recipe_time(recipe_name, time)
|
function util.set_recipe_time(recipe_name, time)
|
||||||
me.add_modified(recipe_name)
|
me.add_modified(recipe_name)
|
||||||
if data.raw.recipe[recipe_name] then
|
if data.raw.recipe[recipe_name] then
|
||||||
if me.bypass[recipe_name] then return end
|
if bypass(recipe_name) then return end
|
||||||
set_recipe_time(data.raw.recipe[recipe_name], time)
|
set_recipe_time(data.raw.recipe[recipe_name], time)
|
||||||
set_recipe_time(data.raw.recipe[recipe_name].normal, time)
|
set_recipe_time(data.raw.recipe[recipe_name].normal, time)
|
||||||
set_recipe_time(data.raw.recipe[recipe_name].expensive, time)
|
set_recipe_time(data.raw.recipe[recipe_name].expensive, time)
|
||||||
|
|
@ -634,7 +658,7 @@ end
|
||||||
function util.multiply_time(recipe_name, factor)
|
function util.multiply_time(recipe_name, factor)
|
||||||
me.add_modified(recipe_name)
|
me.add_modified(recipe_name)
|
||||||
if data.raw.recipe[recipe_name] then
|
if data.raw.recipe[recipe_name] then
|
||||||
if me.bypass[recipe_name] then return end
|
if bypass(recipe_name) then return end
|
||||||
multiply_time(data.raw.recipe[recipe_name], factor)
|
multiply_time(data.raw.recipe[recipe_name], factor)
|
||||||
multiply_time(data.raw.recipe[recipe_name].normal, factor)
|
multiply_time(data.raw.recipe[recipe_name].normal, factor)
|
||||||
multiply_time(data.raw.recipe[recipe_name].expensive, factor)
|
multiply_time(data.raw.recipe[recipe_name].expensive, factor)
|
||||||
|
|
@ -653,7 +677,7 @@ end
|
||||||
function util.add_time(recipe_name, amount)
|
function util.add_time(recipe_name, amount)
|
||||||
me.add_modified(recipe_name)
|
me.add_modified(recipe_name)
|
||||||
if data.raw.recipe[recipe_name] then
|
if data.raw.recipe[recipe_name] then
|
||||||
if me.bypass[recipe_name] then return end
|
if bypass(recipe_name) then return end
|
||||||
add_time(data.raw.recipe[recipe_name], amount)
|
add_time(data.raw.recipe[recipe_name], amount)
|
||||||
add_time(data.raw.recipe[recipe_name].normal, amount)
|
add_time(data.raw.recipe[recipe_name].normal, amount)
|
||||||
add_time(data.raw.recipe[recipe_name].expensive, amount)
|
add_time(data.raw.recipe[recipe_name].expensive, amount)
|
||||||
|
|
@ -670,7 +694,7 @@ end
|
||||||
|
|
||||||
-- Set recipe category
|
-- Set recipe category
|
||||||
function util.set_category(recipe_name, category)
|
function util.set_category(recipe_name, category)
|
||||||
if me.bypass[recipe_name] then return end
|
if bypass(recipe_name) then return end
|
||||||
if data.raw.recipe[recipe_name] and data.raw["recipe-category"][category] then
|
if data.raw.recipe[recipe_name] and data.raw["recipe-category"][category] then
|
||||||
me.add_modified(recipe_name)
|
me.add_modified(recipe_name)
|
||||||
data.raw.recipe[recipe_name].category = category
|
data.raw.recipe[recipe_name].category = category
|
||||||
|
|
@ -679,7 +703,7 @@ end
|
||||||
|
|
||||||
-- Set recipe subgroup
|
-- Set recipe subgroup
|
||||||
function util.set_subgroup(recipe_name, subgroup)
|
function util.set_subgroup(recipe_name, subgroup)
|
||||||
if me.bypass[recipe_name] then return end
|
if bypass(recipe_name) then return end
|
||||||
if data.raw.recipe[recipe_name] then
|
if data.raw.recipe[recipe_name] then
|
||||||
me.add_modified(recipe_name)
|
me.add_modified(recipe_name)
|
||||||
data.raw.recipe[recipe_name].subgroup = subgroup
|
data.raw.recipe[recipe_name].subgroup = subgroup
|
||||||
|
|
@ -688,7 +712,7 @@ end
|
||||||
|
|
||||||
-- Set item subgroup
|
-- Set item subgroup
|
||||||
function util.set_item_subgroup(item, subgroup)
|
function util.set_item_subgroup(item, subgroup)
|
||||||
if me.bypass[item] then return end
|
if bypass(item) then return end
|
||||||
if data.raw.item[item] and data.raw["item-subgroup"][subgroup] then
|
if data.raw.item[item] and data.raw["item-subgroup"][subgroup] then
|
||||||
data.raw.item[item].subgroup = subgroup
|
data.raw.item[item].subgroup = subgroup
|
||||||
end
|
end
|
||||||
|
|
@ -696,7 +720,7 @@ end
|
||||||
|
|
||||||
-- Set recipe icons
|
-- Set recipe icons
|
||||||
function util.set_icons(recipe_name, icons)
|
function util.set_icons(recipe_name, icons)
|
||||||
if me.bypass[recipe_name] then return end
|
if bypass(recipe_name) then return end
|
||||||
if data.raw.recipe[recipe_name] then
|
if data.raw.recipe[recipe_name] then
|
||||||
me.add_modified(recipe_name)
|
me.add_modified(recipe_name)
|
||||||
data.raw.recipe[recipe_name].icons = icons
|
data.raw.recipe[recipe_name].icons = icons
|
||||||
|
|
@ -755,6 +779,7 @@ function add_to_ingredient(recipe, it, amount)
|
||||||
end
|
end
|
||||||
|
|
||||||
function util.add_to_product(recipe, product, amount)
|
function util.add_to_product(recipe, product, amount)
|
||||||
|
if bypass(recipe) then return end
|
||||||
if data.raw.recipe[recipe] then
|
if data.raw.recipe[recipe] then
|
||||||
add_to_product(data.raw.recipe[recipe], product, amount)
|
add_to_product(data.raw.recipe[recipe], product, amount)
|
||||||
add_to_product(data.raw.recipe[recipe].normal, product, amount)
|
add_to_product(data.raw.recipe[recipe].normal, product, amount)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "bzsilicon",
|
"name": "bzsilicon",
|
||||||
"version": "0.11.2",
|
"version": "0.11.3",
|
||||||
"factorio_version": "1.1",
|
"factorio_version": "1.1",
|
||||||
"title": "Silica & Silicon",
|
"title": "Silica & Silicon",
|
||||||
"author": "Brevven",
|
"author": "Brevven",
|
||||||
|
|
|
||||||
2
me.lua
2
me.lua
|
|
@ -3,10 +3,12 @@ me.name = "bzsilicon"
|
||||||
me.silicon_processing = mods["Krastorio2"] and "kr-silicon-processing" or "silicon-processing"
|
me.silicon_processing = mods["Krastorio2"] and "kr-silicon-processing" or "silicon-processing"
|
||||||
|
|
||||||
function me.use_gyros()
|
function me.use_gyros()
|
||||||
|
if me.get_setting("bz-all-intermediates") then return true end
|
||||||
return me.get_setting("bzsilicon-more-intermediates") == "more"
|
return me.get_setting("bzsilicon-more-intermediates") == "more"
|
||||||
end
|
end
|
||||||
|
|
||||||
function me.more_intermediates()
|
function me.more_intermediates()
|
||||||
|
if me.get_setting("bz-all-intermediates") then return true end
|
||||||
return mods["Bio_Industries"] or me.get_setting("bzsilicon-more-intermediates") == "yes" or me.use_gyros()
|
return mods["Bio_Industries"] or me.get_setting("bzsilicon-more-intermediates") == "yes" or me.use_gyros()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue