Compare commits

..

No commits in common. "main" and "main" have entirely different histories.
main ... main

3 changed files with 33 additions and 61 deletions

View file

@ -1,12 +0,0 @@
---------------------------------------------------------------------------------------------------
Version: 1.1.0
Date: 13.03.2026
Changes:
- Add get_setting
- Make `me` optional
---------------------------------------------------------------------------------------------------
Version: 1.0.1
Date: 11.03.2026
Bug Fixes:
- K2: Fix bug in matter recipe generation
- Fix bug in add_icon when icons table is nil

View file

@ -3,10 +3,11 @@
-- WARNING WARNING WARNING -- WARNING WARNING WARNING
local futil = require("util") local futil = require("util")
local me local me = require("me")
local util = {} local util = {}
util.me = nil util.me = me
util.get_setting = util.me.get_setting
util.bz = {} util.bz = {}
util.bz.carbon = mods["bzcarbon"] and "bzcarbon" or mods["bzcarbon2"] and "bzcarbon2" util.bz.carbon = mods["bzcarbon"] and "bzcarbon" or mods["bzcarbon2"] and "bzcarbon2"
@ -75,18 +76,6 @@ util.vacuum_icon = { icon = "__base__/graphics/icons/fluid/steam.png", tint = {
util.vacuum_icon_small = { icon = "__base__/graphics/icons/fluid/steam.png", tint = { r = .1, g = .1, b = .5, a = .5 }, scale = 0.25, shift = { -8, -8 }, } util.vacuum_icon_small = { icon = "__base__/graphics/icons/fluid/steam.png", tint = { r = .1, g = .1, b = .5, a = .5 }, scale = 0.25, shift = { -8, -8 }, }
util.vacuum_vis = { r = .1, g = .1, b = .5 } util.vacuum_vis = { r = .1, g = .1, b = .5 }
function util.initialize(them)
me = them
util.me = me
end
function util.get_setting(name)
if settings.startup[name] == nil then
return nil
end
return settings.startup[name].value
end
function util.item(item, quantity, probability) function util.item(item, quantity, probability)
if not quantity then if not quantity then
quantity = 1 quantity = 1
@ -124,13 +113,13 @@ end
allbypass = {} allbypass = {}
if get_setting("bz-recipe-bypass") then if get_setting("bz-recipe-bypass") then
for recipe in string.gmatch(util.get_setting("bz-recipe-bypass"), '[^",%s]+') do for recipe in string.gmatch(me.get_setting("bz-recipe-bypass"), '[^",%s]+') do
allbypass[recipe] = true allbypass[recipe] = true
end end
end end
function util.is_foundry() function util.is_foundry()
return util.bz.foundry and not util.get_setting("bzfoundry-minimal") return mods.bzfoundry2 and not me.get_setting("bzfoundry-minimal")
end end
function should_force(options) function should_force(options)
@ -138,7 +127,7 @@ function should_force(options)
end end
function bypass(recipe_name) function bypass(recipe_name)
if me and me.bypass[recipe_name] then if me.bypass[recipe_name] then
return true return true
end end
if allbypass[recipe_name] then if allbypass[recipe_name] then
@ -423,7 +412,7 @@ function util.add_gleba_rock(resource, amount_min, amount_max)
}) })
local probability = data.raw["simple-entity"]["gleba-rock"].autoplace.probability_expression local probability = data.raw["simple-entity"]["gleba-rock"].autoplace.probability_expression
-- A lot more common near starting point when aps gleba -- A lot more common near starting point when aps gleba
local factor = (mods["any-planet-start"] and util.get_setting("aps-planet") == "gleba" and 20) or 1 local factor = (mods["any-planet-start"] and me.get_setting("aps-planet") == "gleba" and 20) or 1
data.raw["simple-entity"]["gleba-rock"].autoplace.probability_expression = probability .. [[* data.raw["simple-entity"]["gleba-rock"].autoplace.probability_expression = probability .. [[*
if(distance_from_nearest_point{x = x, y = y, points = starting_positions} < 200, ]] .. factor .. [[, if(distance_from_nearest_point{x = x, y = y, points = starting_positions} < 200, ]] .. factor .. [[,
if(distance_from_nearest_point{x = x, y = y, points = starting_positions} < 700, if(distance_from_nearest_point{x = x, y = y, points = starting_positions} < 700,
@ -432,8 +421,8 @@ function util.add_gleba_rock(resource, amount_min, amount_max)
end end
if data.raw.item[resource] then if data.raw.item[resource] then
amount_min = (amount_min or 10) * ((mods["any-planet-start"] and util.get_setting("aps-planet") == "gleba" and 4) or 1) amount_min = (amount_min or 10) * ((mods["any-planet-start"] and me.get_setting("aps-planet") == "gleba" and 4) or 1)
amount_max = (amount_max or 20) * ((mods["any-planet-start"] and util.get_setting("aps-planet") == "gleba" and 4) or 1) amount_max = (amount_max or 20) * ((mods["any-planet-start"] and me.get_setting("aps-planet") == "gleba" and 4) or 1)
util.add_minable_result( util.add_minable_result(
"simple-entity", "gleba-rock", "simple-entity", "gleba-rock",
{ type = "item", name = resource, amount_min = amount_min, amount_max = amount_max }) { type = "item", name = resource, amount_min = amount_min, amount_max = amount_max })
@ -536,7 +525,7 @@ function util.se_landfill(params)
type = "recipe", type = "recipe",
icons = { icons = {
{ icon = "__base__/graphics/icons/landfill.png", icon_size = 64, icon_mipmaps = 3 }, { icon = "__base__/graphics/icons/landfill.png", icon_size = 64, icon_mipmaps = 3 },
{ icon = "__" .. (me and me.name or params.ore) .. "__/graphics/icons/" .. params.ore .. ".png", icon_size = params.icon_size, scale = 0.33 * 64 / params.icon_size }, { icon = "__" .. me.name .. "__/graphics/icons/" .. params.ore .. ".png", icon_size = params.icon_size, scale = 0.33 * 64 / params.icon_size },
}, },
energy_required = 1, energy_required = 1,
enabled = false, enabled = false,
@ -607,7 +596,7 @@ function util.k2matter(params)
time = 45, time = 45,
}, },
effects = {}, effects = {},
localised_name = { "technology-name.k2-conversion", { "item-name." .. params.k2matter.material.name } }, localised_name = { "technology-name.k2-conversion", { "item-name." .. params.k2matter.item_name } },
}, },
}) })
end end
@ -644,7 +633,7 @@ function util.se_matter(params)
icon_size = 64, scale = 0.5 }, icon_size = 64, scale = 0.5 },
{ icon = "__space-exploration-graphics__/graphics/icons/fluid/particle-stream.png", { icon = "__space-exploration-graphics__/graphics/icons/fluid/particle-stream.png",
icon_size = 64, scale = 0.33, shift = { 8, -8 } }, icon_size = 64, scale = 0.33, shift = { 8, -8 } },
{ icon = "__" .. (me and me.name or params.ore) .. "__/graphics/icons/" .. params.ore .. ".png", { icon = "__" .. util.me.name .. "__/graphics/icons/" .. params.ore .. ".png",
icon_size = params.icon_size, scale = 0.33 * 64 / params.icon_size, shift = { -8, 8 } }, icon_size = params.icon_size, scale = 0.33 * 64 / params.icon_size, shift = { -8, 8 } },
{ icon = "__space-exploration-graphics__/graphics/icons/transition-arrow.png", { icon = "__space-exploration-graphics__/graphics/icons/transition-arrow.png",
icon_size = 64, scale = 0.5 }, icon_size = 64, scale = 0.5 },
@ -683,7 +672,7 @@ function util.se_matter(params)
icon_size = 64, scale = 0.5 }, icon_size = 64, scale = 0.5 },
{ icon = "__space-exploration-graphics__/graphics/icons/fluid/particle-stream.png", { icon = "__space-exploration-graphics__/graphics/icons/fluid/particle-stream.png",
icon_size = 64, scale = 0.33, shift = { -8, 8 } }, icon_size = 64, scale = 0.33, shift = { -8, 8 } },
{ icon = "__" .. (me and me.name or params.ore) .. "__/graphics/icons/" .. params.ore .. ".png", { icon = "__" .. util.me.name .. "__/graphics/icons/" .. params.ore .. ".png",
icon_size = params.icon_size, scale = 0.33 * 64 / params.icon_size, shift = { 8, -8 } }, icon_size = params.icon_size, scale = 0.33 * 64 / params.icon_size, shift = { 8, -8 } },
{ icon = "__space-exploration-graphics__/graphics/icons/transition-arrow.png", { icon = "__space-exploration-graphics__/graphics/icons/transition-arrow.png",
icon_size = 64, scale = 0.5 }, icon_size = 64, scale = 0.5 },
@ -967,7 +956,7 @@ function util.add_ingredient(recipe_name, ingredient, quantity, options)
end 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 (util.get_item(ingredient) or is_fluid) then if data.raw.recipe[recipe_name] and (util.get_item(ingredient) or is_fluid) then
if me then me.add_modified(recipe_name) end me.add_modified(recipe_name)
prepare_redo_recycling(recipe_name) prepare_redo_recycling(recipe_name)
add_ingredient(data.raw.recipe[recipe_name], ingredient, quantity, is_fluid) add_ingredient(data.raw.recipe[recipe_name], ingredient, quantity, is_fluid)
end end
@ -1018,7 +1007,7 @@ function util.set_ingredient(recipe_name, ingredient, quantity, options)
end 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
local is_fluid = not not data.raw.fluid[ingredient] local is_fluid = not not data.raw.fluid[ingredient]
if me then me.add_modified(recipe_name) end me.add_modified(recipe_name)
prepare_redo_recycling(recipe_name) prepare_redo_recycling(recipe_name)
set_ingredient(data.raw.recipe[recipe_name], ingredient, quantity, is_fluid) set_ingredient(data.raw.recipe[recipe_name], ingredient, quantity, is_fluid)
end end
@ -1130,7 +1119,7 @@ function util.replace_ingredient(recipe_name, old, new, amount, multiply, option
return return
end end
if data.raw.recipe[recipe_name] and (data.raw.item[new] or data.raw.fluid[new]) and (data.raw.item[old] or data.raw.fluid[old]) then if data.raw.recipe[recipe_name] and (data.raw.item[new] or data.raw.fluid[new]) and (data.raw.item[old] or data.raw.fluid[old]) then
if me then me.add_modified(recipe_name) end me.add_modified(recipe_name)
prepare_redo_recycling(recipe_name) prepare_redo_recycling(recipe_name)
replace_ingredient(data.raw.recipe[recipe_name], old, new, amount, multiply) replace_ingredient(data.raw.recipe[recipe_name], old, new, amount, multiply)
end end
@ -1164,7 +1153,7 @@ function util.remove_ingredient(recipe_name, old, options)
return return
end end
if data.raw.recipe[recipe_name] then if data.raw.recipe[recipe_name] then
if me then me.add_modified(recipe_name) end me.add_modified(recipe_name)
prepare_redo_recycling(recipe_name) prepare_redo_recycling(recipe_name)
remove_ingredient(data.raw.recipe[recipe_name], old) remove_ingredient(data.raw.recipe[recipe_name], old)
end end
@ -1192,7 +1181,7 @@ function util.replace_some_product(recipe_name, old, old_amount, new, new_amount
end end
local is_fluid = not not data.raw.fluid[new] -- NOTE CURRENTLY UNUSUED local is_fluid = not not data.raw.fluid[new] -- NOTE CURRENTLY UNUSUED
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
if me then me.add_modified(recipe_name) end me.add_modified(recipe_name)
prepare_redo_recycling(recipe_name) prepare_redo_recycling(recipe_name)
replace_some_product(data.raw.recipe[recipe_name], old, old_amount, new, new_amount, is_fluid) replace_some_product(data.raw.recipe[recipe_name], old, old_amount, new, new_amount, is_fluid)
end end
@ -1226,7 +1215,7 @@ function util.replace_some_ingredient(recipe_name, old, old_amount, new, new_amo
end 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
if me then me.add_modified(recipe_name) end me.add_modified(recipe_name)
prepare_redo_recycling(recipe_name) prepare_redo_recycling(recipe_name)
replace_some_ingredient(data.raw.recipe[recipe_name], old, old_amount, new, new_amount, is_fluid) replace_some_ingredient(data.raw.recipe[recipe_name], old, old_amount, new, new_amount, is_fluid)
end end
@ -1254,7 +1243,7 @@ function util.set_product_probability(recipe_name, product, probability, options
return return
end end
if data.raw.recipe[recipe_name] then if data.raw.recipe[recipe_name] then
if me then me.add_modified(recipe_name) end me.add_modified(recipe_name)
prepare_redo_recycling(recipe_name) prepare_redo_recycling(recipe_name)
set_product_probability(data.raw.recipe[recipe_name], product, probability) set_product_probability(data.raw.recipe[recipe_name], product, probability)
end end
@ -1278,7 +1267,7 @@ function util.set_product_amount(recipe_name, product, amount, options)
return return
end end
if data.raw.recipe[recipe_name] then if data.raw.recipe[recipe_name] then
if me then me.add_modified(recipe_name) end me.add_modified(recipe_name)
prepare_redo_recycling(recipe_name) prepare_redo_recycling(recipe_name)
set_product_amount(data.raw.recipe[recipe_name], product, amount) set_product_amount(data.raw.recipe[recipe_name], product, amount)
end end
@ -1309,7 +1298,7 @@ function util.multiply_recipe(recipe_name, multiple, options)
return return
end end
if data.raw.recipe[recipe_name] then if data.raw.recipe[recipe_name] then
if me then me.add_modified(recipe_name) end me.add_modified(recipe_name)
prepare_redo_recycling(recipe_name) prepare_redo_recycling(recipe_name)
multiply_recipe(data.raw.recipe[recipe_name], multiple) multiply_recipe(data.raw.recipe[recipe_name], multiple)
end end
@ -1351,7 +1340,7 @@ function util.multiply_ingredients(recipe_name, multiple, options)
return return
end end
if data.raw.recipe[recipe_name] then if data.raw.recipe[recipe_name] then
if me then me.add_modified(recipe_name) end me.add_modified(recipe_name)
prepare_redo_recycling(recipe_name) prepare_redo_recycling(recipe_name)
multiply_ingredients(data.raw.recipe[recipe_name], multiple) multiply_ingredients(data.raw.recipe[recipe_name], multiple)
end end
@ -1392,7 +1381,7 @@ function util.remove_product(recipe_name, old, options)
return return
end end
if data.raw.recipe[recipe_name] then if data.raw.recipe[recipe_name] then
if me then me.add_modified(recipe_name) end me.add_modified(recipe_name)
prepare_redo_recycling(recipe_name) prepare_redo_recycling(recipe_name)
remove_product(data.raw.recipe[recipe_name], old) remove_product(data.raw.recipe[recipe_name], old)
end end
@ -1475,7 +1464,7 @@ function util.set_recipe_time(recipe_name, time, options)
return return
end end
if data.raw.recipe[recipe_name] then if data.raw.recipe[recipe_name] then
if me then me.add_modified(recipe_name) end me.add_modified(recipe_name)
prepare_redo_recycling(recipe_name) prepare_redo_recycling(recipe_name)
set_recipe_time(data.raw.recipe[recipe_name], time) set_recipe_time(data.raw.recipe[recipe_name], time)
end end
@ -1495,7 +1484,7 @@ function util.multiply_time(recipe_name, factor, options)
return return
end end
if data.raw.recipe[recipe_name] then if data.raw.recipe[recipe_name] then
if me then me.add_modified(recipe_name) end me.add_modified(recipe_name)
prepare_redo_recycling(recipe_name) prepare_redo_recycling(recipe_name)
multiply_time(data.raw.recipe[recipe_name], factor) multiply_time(data.raw.recipe[recipe_name], factor)
end end
@ -1515,7 +1504,7 @@ function util.add_time(recipe_name, amount, options)
return return
end end
if data.raw.recipe[recipe_name] then if data.raw.recipe[recipe_name] then
if me then me.add_modified(recipe_name) end me.add_modified(recipe_name)
prepare_redo_recycling(recipe_name) prepare_redo_recycling(recipe_name)
add_time(data.raw.recipe[recipe_name], amount) add_time(data.raw.recipe[recipe_name], amount)
end end
@ -1542,7 +1531,7 @@ function util.set_category(recipe_name, category, options)
return return
end 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
if me then me.add_modified(recipe_name) end me.add_modified(recipe_name)
prepare_redo_recycling(recipe_name) prepare_redo_recycling(recipe_name)
data.raw.recipe[recipe_name].category = category data.raw.recipe[recipe_name].category = category
end end
@ -1554,7 +1543,7 @@ function util.set_subgroup(recipe_name, subgroup, options)
return return
end end
if data.raw.recipe[recipe_name] and data.raw["item-subgroup"][subgroup] then if data.raw.recipe[recipe_name] and data.raw["item-subgroup"][subgroup] then
if me then me.add_modified(recipe_name) end me.add_modified(recipe_name)
data.raw.recipe[recipe_name].subgroup = subgroup data.raw.recipe[recipe_name].subgroup = subgroup
end end
end end
@ -1574,7 +1563,7 @@ function util.add_icon(recipe_name, icon, options)
return return
end end
if data.raw.recipe[recipe_name] then if data.raw.recipe[recipe_name] then
if me then me.add_modified(recipe_name) end me.add_modified(recipe_name)
if not (data.raw.recipe[recipe_name].icons and #(data.raw.recipe[recipe_name].icons) > 0) then if not (data.raw.recipe[recipe_name].icons and #(data.raw.recipe[recipe_name].icons) > 0) then
if data.raw.recipe[recipe_name].icon then if data.raw.recipe[recipe_name].icon then
data.raw.recipe[recipe_name].icons = { { data.raw.recipe[recipe_name].icons = { {
@ -1598,7 +1587,6 @@ function util.add_icon(recipe_name, icon, options)
data.raw.recipe[recipe_name].icon = nil data.raw.recipe[recipe_name].icon = nil
data.raw.recipe[recipe_name].icon_size = nil data.raw.recipe[recipe_name].icon_size = nil
end end
data.raw.recipe[recipe_name].icons = data.raw.recipe[recipe_name].icons or {}
table.insert(data.raw.recipe[recipe_name].icons, icon) table.insert(data.raw.recipe[recipe_name].icons, icon)
end end
end end
@ -1609,7 +1597,7 @@ function util.set_icons(recipe_name, icons, options)
return return
end end
if data.raw.recipe[recipe_name] then if data.raw.recipe[recipe_name] then
if me then me.add_modified(recipe_name) end me.add_modified(recipe_name)
data.raw.recipe[recipe_name].icons = icons data.raw.recipe[recipe_name].icons = icons
data.raw.recipe[recipe_name].icon = nil data.raw.recipe[recipe_name].icon = nil
data.raw.recipe[recipe_name].icon_size = nil data.raw.recipe[recipe_name].icon_size = nil
@ -1622,7 +1610,7 @@ function util.set_tech_icons(technology, icons, options)
return return
end end
if data.raw.technology[technology] then if data.raw.technology[technology] then
if me then me.add_modified(technology) end me.add_modified(technology)
data.raw.technology[technology].icons = icons data.raw.technology[technology].icons = icons
data.raw.technology[technology].icon = nil data.raw.technology[technology].icon = nil
data.raw.technology[technology].icon_size = nil data.raw.technology[technology].icon_size = nil
@ -1967,10 +1955,6 @@ function util.sum_products(recipe_name)
return 0 return 0
end end
function util.add_productivity(recipe)
data.raw.recipe[recipe].allow_productivity = true
end
function util.set_vtk_dcm_ingredients() function util.set_vtk_dcm_ingredients()
if mods["vtk-deep-core-mining"] then if mods["vtk-deep-core-mining"] then
local sum = util.sum_products("vtk-deepcore-mining-ore-chunk-refining") local sum = util.sum_products("vtk-deepcore-mining-ore-chunk-refining")

View file

@ -1,6 +1,6 @@
{ {
"name": "bzlib", "name": "bzlib",
"version": "1.1.0", "version": "1.0.0",
"factorio_version": "2.0", "factorio_version": "2.0",
"title": "BZ Lib", "title": "BZ Lib",
"description": "Library code for BZ mods", "description": "Library code for BZ mods",