bypass setting
This commit is contained in:
parent
6f924dcef9
commit
d8d87fa7f2
8 changed files with 187 additions and 54 deletions
|
|
@ -1,4 +1,9 @@
|
|||
---------------------------------------------------------------------------------------------------
|
||||
Version: 0.5.0
|
||||
Date: 2021-06-16
|
||||
Features:
|
||||
- Recipe bypass setting
|
||||
---------------------------------------------------------------------------------------------------
|
||||
Version: 0.4.11
|
||||
Date: 2021-06-13
|
||||
Features:
|
||||
|
|
|
|||
|
|
@ -21,12 +21,12 @@ end
|
|||
if mods["Krastorio2"] then
|
||||
util.replace_ingredient("rifle-magazine", "iron-plate", "lead-plate")
|
||||
util.replace_ingredient("anti-material-rifle-magazine", "iron-plate", "lead-plate")
|
||||
util.replace_some_ingredient("kr-crusher", "iron-beam", "lead-plate", 5)
|
||||
util.replace_some_ingredient("kr-crusher", "iron-beam", 5, "lead-plate", 5)
|
||||
util.replace_ingredient("kr-shelter", "iron-plate", "lead-plate")
|
||||
util.add_ingredient("kr-advanced-furnace", "lead-plate", 20)
|
||||
util.replace_ingredient("uranium-fuel-cell", "steel-plate", "lead-plate")
|
||||
util.replace_some_ingredient("kr-fluid-storage-1", "steel-plate", "lead-plate", 10)
|
||||
util.replace_some_ingredient("kr-fluid-storage-2", "steel-plate", "lead-plate", 30)
|
||||
util.replace_some_ingredient("kr-fluid-storage-1", "steel-plate", 10, "lead-plate", 10)
|
||||
util.replace_some_ingredient("kr-fluid-storage-2", "steel-plate", 30, "lead-plate", 30)
|
||||
end
|
||||
|
||||
if mods["modmashsplintergold"] then
|
||||
|
|
@ -37,8 +37,8 @@ if mods["modmashsplintergold"] then
|
|||
end
|
||||
|
||||
if mods["space-exploration"] then
|
||||
util.replace_some_ingredient("se-pulveriser", "iron-plate", "lead-plate", 10)
|
||||
util.replace_some_ingredient("se-canister", "copper-plate", "lead-plate", 5)
|
||||
util.replace_some_ingredient("se-pulveriser", "iron-plate", 10, "lead-plate", 10)
|
||||
util.replace_some_ingredient("se-canister", "copper-plate", 5, "lead-plate", 5)
|
||||
util.add_ingredient("industrial-furnace", "lead-plate", 16)
|
||||
|
||||
util.add_ingredient("se-material-testing-pack", "lead-plate", 1)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "bzlead",
|
||||
"version": "0.4.11",
|
||||
"version": "0.5.0",
|
||||
"factorio_version": "1.1",
|
||||
"title": "Lead",
|
||||
"author": "Brevven",
|
||||
|
|
|
|||
|
|
@ -110,9 +110,9 @@ if mods["5dim_core"] then
|
|||
local items = {"5d-gun-turret-", "5d-gun-turret-big-", "5d-gun-turret-small-"}
|
||||
for i, mk in pairs(mks) do
|
||||
for j, item in pairs(items) do
|
||||
util.replace_some_ingredient(item..mk, "iron-plate", "lead-plate", 2)
|
||||
util.replace_some_ingredient(item..mk, "iron-plate", 2, "lead-plate", 2)
|
||||
end
|
||||
util.replace_some_ingredient("5d-gun-turret-sniper-"..mk, "steel-plate", "lead-plate", 1)
|
||||
util.replace_some_ingredient("5d-gun-turret-sniper-"..mk, "steel-plate", 1, "lead-plate", 1)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ local util = require("__bzlead__.util");
|
|||
if (not mods["pyrawores"] and not mods["bobplates"] and not mods["angelssmelting"]) then
|
||||
util.replace_ingredient("pipe", "iron-plate", "lead-plate")
|
||||
util.replace_ingredient("pipe-to-ground", "iron-plate", "lead-plate")
|
||||
util.replace_some_ingredient("storage-tank", "iron-plate", "lead-plate", 10)
|
||||
util.replace_some_ingredient("storage-tank", "iron-plate", 10, "lead-plate", 10)
|
||||
util.replace_ingredient("battery", "iron-plate", "lead-plate")
|
||||
|
||||
|
||||
|
|
@ -14,7 +14,7 @@ if (not mods["pyrawores"] and not mods["bobplates"] and not mods["angelssmelting
|
|||
end
|
||||
|
||||
util.replace_ingredient("uranium-fuel-cell", "iron-plate", "lead-plate")
|
||||
util.replace_some_ingredient("gun-turret", "iron-plate", "lead-plate", 4)
|
||||
util.replace_some_ingredient("gun-turret", "iron-plate", 4, "lead-plate", 4)
|
||||
|
||||
util.add_ingredient("big-electric-pole", "lead-plate", 2)
|
||||
util.add_ingredient("substation", "lead-plate", 2)
|
||||
|
|
@ -38,16 +38,16 @@ util.add_product("se-scrap-recycling", {name="lead-ore", amount=1, probability=0
|
|||
|
||||
if mods["WeaponPack"] then
|
||||
util.replace_ingredient("9x18", "iron-plate", "lead-plate")
|
||||
util.replace_some_ingredient("9x19", "iron-plate", "lead-plate", 1)
|
||||
util.replace_some_ingredient("7,62x25", "iron-plate", "lead-plate", 9)
|
||||
util.replace_some_ingredient("7,62x51", "iron-plate", "lead-plate", 11)
|
||||
util.replace_some_ingredient("5,56x45", "iron-plate", "lead-plate", 9)
|
||||
util.replace_some_ingredient("5,45x39", "iron-plate", "lead-plate", 7)
|
||||
util.replace_some_ingredient("5,7x28", "iron-plate", "lead-plate", 7)
|
||||
util.replace_some_ingredient("5,7 × 28", "iron-plate", "lead-plate", 7)
|
||||
util.replace_some_ingredient("357", "iron-plate", "lead-plate", 9)
|
||||
util.replace_some_ingredient("45acp", "iron-plate", "lead-plate", 7)
|
||||
util.replace_some_ingredient("12gauge", "iron-plate", "lead-plate", 3)
|
||||
util.replace_some_ingredient("9x19", "iron-plate", 1, "lead-plate", 1)
|
||||
util.replace_some_ingredient("7,62x25", "iron-plate", 9, "lead-plate", 9)
|
||||
util.replace_some_ingredient("7,62x51", "iron-plate", 11, "lead-plate", 11)
|
||||
util.replace_some_ingredient("5,56x45", "iron-plate", 9, "lead-plate", 9)
|
||||
util.replace_some_ingredient("5,45x39", "iron-plate", 7, "lead-plate", 7)
|
||||
util.replace_some_ingredient("5,7x28", "iron-plate", 7, "lead-plate", 7)
|
||||
util.replace_some_ingredient("5,7 × 28", "iron-plate", 7, "lead-plate", 7)
|
||||
util.replace_some_ingredient("357", "iron-plate", 9, "lead-plate", 9)
|
||||
util.replace_some_ingredient("45acp", "iron-plate", 7, "lead-plate", 7)
|
||||
util.replace_some_ingredient("12gauge", "iron-plate", 3, "lead-plate", 3)
|
||||
end
|
||||
|
||||
if mods["More_Ammo"] then
|
||||
|
|
@ -69,7 +69,7 @@ util.replace_ingredient("small-coal-cannon-shell", "copper-plate", "lead-plate")
|
|||
util.add_ingredient("at_A1_b","lead-plate", 20)
|
||||
|
||||
-- Other one-offs
|
||||
util.replace_some_ingredient("zinfinite_buffer_fluid_tank1", "iron-plate", "lead-plate", 1000)
|
||||
util.replace_some_ingredient("zinfinite_buffer_fluid_tank1", "iron-plate", 1000, "lead-plate", 1000)
|
||||
util.add_ingredient("storage-tank2", "lead-plate", 32)
|
||||
util.add_ingredient("advanced-substation", "lead-plate", 20)
|
||||
util.add_ingredient("substation-2", "lead-plate", 20)
|
||||
|
|
@ -103,9 +103,9 @@ util.add_ingredient("kr-heavy-machine-gun-turret", "lead-plate", 10)
|
|||
|
||||
-- King Jo
|
||||
util.replace_ingredient("bolt75mk1", "steel-plate", "lead-plate")
|
||||
util.replace_some_ingredient("bolt100mk1", "steel-plate", "lead-plate", 3)
|
||||
util.replace_some_ingredient("bolt75metalstorm", "steel-plate", "lead-plate", 2)
|
||||
util.replace_some_ingredient("bolt100metalstorm", "steel-plate", "lead-plate", 5)
|
||||
util.replace_some_ingredient("bolt100mk1", "steel-plate", 3, "lead-plate", 3)
|
||||
util.replace_some_ingredient("bolt75metalstorm", "steel-plate", 3, "lead-plate", 2)
|
||||
util.replace_some_ingredient("bolt100metalstorm", "steel-plate", 5, "lead-plate", 5)
|
||||
|
||||
|
||||
-- Geothermal
|
||||
|
|
|
|||
|
|
@ -40,9 +40,11 @@ dirty-water-filtration-lead=Filter dirty water, giving lead ore [item=lead-ore],
|
|||
# Settings
|
||||
|
||||
[mod-setting-name]
|
||||
bzlead-recipe-bypass=Bypass recipes
|
||||
bzlead-more-entities=Lead entities
|
||||
bzlead-sulfuric=Use lead in sulfuric acid. Default "yes". Use with care.
|
||||
|
||||
[mod-setting-description]
|
||||
bzlead-recipe-bypass=Skip modifying these recipes (comma-separated list).
|
||||
bzlead-more-entities=Adds lead entities (currently just a lead chest).
|
||||
bzlead-sulfuric=Adds compatibility for old saves. Do NOT change to "no" for new saves. Will be removed (and always "yes") in 2022.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,11 @@
|
|||
data:extend(
|
||||
data:extend({
|
||||
{
|
||||
type = "string-setting",
|
||||
name = "bzlead-recipe-bypass",
|
||||
setting_type = "startup",
|
||||
default_value = "",
|
||||
allow_blank = true,
|
||||
},
|
||||
{
|
||||
type = "string-setting",
|
||||
name = "bzlead-more-entities",
|
||||
|
|
|
|||
164
util.lua
164
util.lua
|
|
@ -1,8 +1,18 @@
|
|||
local util = {}
|
||||
|
||||
util.name = "bzlead"
|
||||
util.lead_ore = "lead-ore"
|
||||
util.lead_plate = "lead-plate"
|
||||
|
||||
|
||||
function util.more_entities()
|
||||
return util.get_setting("bzlead-more-entities") == "yes"
|
||||
end
|
||||
|
||||
function util.sulfuric()
|
||||
return util.get_setting("bzlead-sulfuric") == "yes"
|
||||
end
|
||||
|
||||
function util.get_setting(name)
|
||||
if settings.startup[name] == nil then
|
||||
return nil
|
||||
|
|
@ -10,12 +20,11 @@ function util.get_setting(name)
|
|||
return settings.startup[name].value
|
||||
end
|
||||
|
||||
function util.more_entities()
|
||||
return util.get_setting("bzlead-more-entities") == "yes"
|
||||
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
|
||||
|
||||
function util.sulfuric()
|
||||
return util.get_setting("bzlead-sulfuric") == "yes"
|
||||
end
|
||||
|
||||
function util.get_stack_size(default)
|
||||
|
|
@ -39,17 +48,51 @@ end
|
|||
-- Add a prerequisite to a given technology
|
||||
function util.add_prerequisite(technology_name, prerequisite)
|
||||
technology = data.raw.technology[technology_name]
|
||||
if technology and data.raw.technology[prerequisite] then
|
||||
if technology.prerequisites then
|
||||
table.insert(technology.prerequisites, prerequisite)
|
||||
else
|
||||
technology.prerequisites = {prerequisite}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Remove a prerequisite from a given technology
|
||||
function util.remove_prerequisite(technology_name, prerequisite)
|
||||
technology = data.raw.technology[technology_name]
|
||||
local index = -1
|
||||
if technology and data.raw.technology[prerequisite] then
|
||||
for i, prereq in pairs(technology.prerequisites) do
|
||||
if prereq == prerequisite then
|
||||
index = i
|
||||
break
|
||||
end
|
||||
end
|
||||
if index > -1 then
|
||||
table.remove(technology.prerequisites, index)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Add an effect to a given technology
|
||||
function util.add_effect(technology_name, effect)
|
||||
technology = data.raw.technology[technology_name]
|
||||
if technology then
|
||||
table.insert(technology.effects, effect)
|
||||
end
|
||||
end
|
||||
|
||||
-- Set technology ingredients
|
||||
function util.set_tech_recipe(technology_name, ingredients)
|
||||
technology = data.raw.technology[technology_name]
|
||||
if technology then
|
||||
technology.unit.ingredients = ingredients
|
||||
end
|
||||
end
|
||||
|
||||
-- Add a given quantity of ingredient to a given recipe
|
||||
function util.add_ingredient(recipe_name, ingredient, quantity)
|
||||
if bypass[recipe_name] then return end
|
||||
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)
|
||||
|
|
@ -59,12 +102,35 @@ end
|
|||
|
||||
function add_ingredient(recipe, ingredient, quantity)
|
||||
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
|
||||
log("Not adding "..ingredient.." -- duplicate")
|
||||
return
|
||||
end
|
||||
end
|
||||
table.insert(recipe.ingredients, {ingredient, quantity})
|
||||
end
|
||||
end
|
||||
|
||||
-- Add a given quantity of product to a given recipe.
|
||||
-- Only works for recipes with multiple products
|
||||
function util.add_product(recipe_name, product)
|
||||
if data.raw.recipe[recipe_name] then
|
||||
add_product(data.raw.recipe[recipe_name], product)
|
||||
add_product(data.raw.recipe[recipe_name].normal, product)
|
||||
add_product(data.raw.recipe[recipe_name].expensive, product)
|
||||
end
|
||||
end
|
||||
|
||||
function add_product(recipe, product)
|
||||
if recipe ~= nil and recipe.results ~= nil then
|
||||
table.insert(recipe.results, product)
|
||||
end
|
||||
end
|
||||
|
||||
-- Replace one ingredient with another in a recipe
|
||||
function util.replace_ingredient(recipe_name, old, new)
|
||||
if bypass[recipe_name] then return end
|
||||
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)
|
||||
|
|
@ -74,6 +140,12 @@ end
|
|||
|
||||
function replace_ingredient(recipe, old, new)
|
||||
if recipe ~= nil and recipe.ingredients ~= nil then
|
||||
for i, existing in pairs(recipe.ingredients) do
|
||||
if existing[1] == new or existing.name == new then
|
||||
log("Not adding "..new.." -- duplicate")
|
||||
return
|
||||
end
|
||||
end
|
||||
for i, ingredient in pairs(recipe.ingredients) do
|
||||
if ingredient.name == old then ingredient.name = new end
|
||||
if ingredient[1] == old then ingredient[1] = new end
|
||||
|
|
@ -83,6 +155,7 @@ end
|
|||
|
||||
-- Remove an ingredient from a recipe
|
||||
function util.remove_ingredient(recipe_name, old)
|
||||
if bypass[recipe_name] then return end
|
||||
if data.raw.recipe[recipe_name] then
|
||||
remove_ingredient(data.raw.recipe[recipe_name], old)
|
||||
remove_ingredient(data.raw.recipe[recipe_name].normal, old)
|
||||
|
|
@ -107,41 +180,88 @@ end
|
|||
|
||||
|
||||
-- Replace an amount of an ingredient in a recipe. Keep at least 1 of old.
|
||||
function util.replace_some_ingredient(recipe_name, old, new, amount)
|
||||
function util.replace_some_ingredient(recipe_name, old, old_amount, new, new_amount)
|
||||
if bypass[recipe_name] then return end
|
||||
if data.raw.recipe[recipe_name] then
|
||||
replace_some_ingredient(data.raw.recipe[recipe_name], old, new, amount)
|
||||
replace_some_ingredient(data.raw.recipe[recipe_name].normal, old, new, amount)
|
||||
replace_some_ingredient(data.raw.recipe[recipe_name].expensive, old, 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].expensive, old, old_amount, new, new_amount)
|
||||
end
|
||||
end
|
||||
|
||||
function replace_some_ingredient(recipe, old, new, amount)
|
||||
function replace_some_ingredient(recipe, old, old_amount, new, new_amount)
|
||||
if recipe ~= nil and recipe.ingredients ~= nil then
|
||||
for i, existing in pairs(recipe.ingredients) do
|
||||
if existing[1] == new or existing.name == new then
|
||||
log("Not adding "..new.." -- duplicate")
|
||||
return
|
||||
end
|
||||
end
|
||||
for i, ingredient in pairs(recipe.ingredients) do
|
||||
-- For final fixes
|
||||
if ingredient.name == old then
|
||||
ingredient.amount = math.max(1, ingredient.amount - amount)
|
||||
ingredient.amount = math.max(1, ingredient.amount - old_amount)
|
||||
end
|
||||
-- For updates
|
||||
if ingredient[1] == old then
|
||||
ingredient[2] = math.max(1, ingredient[2] - amount)
|
||||
ingredient[2] = math.max(1, ingredient[2] - old_amount)
|
||||
end
|
||||
end
|
||||
add_ingredient(recipe, new, amount)
|
||||
add_ingredient(recipe, new, new_amount)
|
||||
end
|
||||
end
|
||||
|
||||
-- Add a given quantity of product to a given recipe.
|
||||
-- Only works for recipes with multiple products
|
||||
function util.add_product(recipe_name, product)
|
||||
-- multiply the cost, energy, and results of a recipe by a multiple
|
||||
function util.multiply_recipe(recipe_name, multiple)
|
||||
if bypass[recipe_name] then return end
|
||||
if data.raw.recipe[recipe_name] then
|
||||
add_product(data.raw.recipe[recipe_name], product)
|
||||
add_product(data.raw.recipe[recipe_name].normal, product)
|
||||
add_product(data.raw.recipe[recipe_name].expensive, product)
|
||||
multiply_recipe(data.raw.recipe[recipe_name], multiple)
|
||||
multiply_recipe(data.raw.recipe[recipe_name].normal, multiple)
|
||||
multiply_recipe(data.raw.recipe[recipe_name].expensive, multiple)
|
||||
end
|
||||
end
|
||||
|
||||
function add_product(recipe, product)
|
||||
if recipe ~= nil and recipe.results ~= nil then
|
||||
table.insert(recipe.results, product)
|
||||
function multiply_recipe(recipe, multiple)
|
||||
if recipe then
|
||||
if recipe.energy_required then
|
||||
recipe.energy_required = recipe.energy_required * multiple
|
||||
end
|
||||
if recipe.result_count then
|
||||
recipe.result_count = recipe.result_count * multiple
|
||||
end
|
||||
if recipe.results then
|
||||
for i, result in pairs(recipe.results) do
|
||||
if result.name then
|
||||
if result.amount then
|
||||
result.amount = result.amount * multiple
|
||||
end
|
||||
if result.amount_min ~= nil then
|
||||
result.amount_min = result.amount_min * multiple
|
||||
result.amount_max = result.amount_max * multiple
|
||||
end
|
||||
if result.catalyst_amount then
|
||||
result.catalyst_amount = result.catalyst_amount * multiple
|
||||
end
|
||||
end
|
||||
if result[1] then
|
||||
result[2] = result[2] * multiple
|
||||
end
|
||||
end
|
||||
end
|
||||
if not recipe.results and not recipe.result_count then
|
||||
-- implicit one item result
|
||||
recipe.result_count = multiple
|
||||
end
|
||||
if recipe.ingredients then
|
||||
for i, ingredient in pairs(recipe.ingredients) do
|
||||
if ingredient.name then
|
||||
ingredient.amount = ingredient.amount * multiple
|
||||
end
|
||||
if ingredient[1] then
|
||||
ingredient[2] = ingredient[2] * multiple
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue