fix recycling
This commit is contained in:
parent
88d7f90a56
commit
d9d92bca17
6 changed files with 80 additions and 27 deletions
|
|
@ -1,4 +1,11 @@
|
||||||
---------------------------------------------------------------------------------------------------
|
---------------------------------------------------------------------------------------------------
|
||||||
|
Version: 2.0.15
|
||||||
|
Date: 2025-01-06
|
||||||
|
Fixes:
|
||||||
|
- Fix crash when used with Quality but not Space Age
|
||||||
|
Changes:
|
||||||
|
- Do more to respect disabling of certain recycling recipes.
|
||||||
|
---------------------------------------------------------------------------------------------------
|
||||||
Version: 2.0.14
|
Version: 2.0.14
|
||||||
Date: 2025-01-05
|
Date: 2025-01-05
|
||||||
Changes:
|
Changes:
|
||||||
|
|
|
||||||
|
|
@ -1,33 +1,23 @@
|
||||||
require("titanium-recipe-final")
|
|
||||||
|
|
||||||
|
|
||||||
-- Space Exploration compatibility and flavor tweaks
|
-- Space Exploration compatibility and flavor tweaks
|
||||||
require("titanium-recipe-final-se")
|
require("titanium-recipe-final-se")
|
||||||
|
|
||||||
-- Krastorio 2 final fixes
|
-- Krastorio 2 final fixes
|
||||||
require("titanium-recipe-final-k2")
|
require("titanium-recipe-final-k2")
|
||||||
|
|
||||||
|
|
||||||
-- Rich Rocks Requiem for Krastorio 2 final fixes
|
-- Rich Rocks Requiem for Krastorio 2 final fixes
|
||||||
require("titanium-recipe-final-rrr")
|
require("titanium-recipe-final-rrr")
|
||||||
|
|
||||||
|
|
||||||
-- Deadlock's stacking and crating
|
-- Deadlock's stacking and crating
|
||||||
require("titanium-recipe-final-stacking")
|
require("titanium-recipe-final-stacking")
|
||||||
|
|
||||||
|
|
||||||
-- 5Dim's final fixes
|
-- 5Dim's final fixes
|
||||||
require("titanium-recipe-final-5d")
|
require("titanium-recipe-final-5d")
|
||||||
|
|
||||||
|
|
||||||
-- Modmash final fixes
|
-- Modmash final fixes
|
||||||
require("titanium-recipe-final-modmash")
|
require("titanium-recipe-final-modmash")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
require("compatibility/248k-final")
|
require("compatibility/248k-final")
|
||||||
|
|
||||||
|
|
||||||
-- Second part of hack for endgame combat
|
-- Second part of hack for endgame combat
|
||||||
require("compatibility/titanium-endgame-combat-final")
|
require("compatibility/titanium-endgame-combat-final")
|
||||||
|
|
||||||
|
|
@ -36,4 +26,6 @@ require("compatibility/titanium-auto-train-depot-final")
|
||||||
|
|
||||||
|
|
||||||
local util = require("__bztitanium__.data-util");
|
local util = require("__bztitanium__.data-util");
|
||||||
|
|
||||||
|
util.size_recycler_output()
|
||||||
util.use_fluid_mining_final()
|
util.use_fluid_mining_final()
|
||||||
|
|
|
||||||
|
|
@ -742,11 +742,13 @@ function util.add_new_crafting_category(category, by_hand)
|
||||||
end
|
end
|
||||||
end
|
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, options)
|
function util.add_or_add_to_ingredient(recipe_name, ingredient, quantity, options)
|
||||||
if not should_force(options) and bypass(recipe_name) then return end
|
if not should_force(options) and 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)
|
||||||
|
prepare_redo_recycling(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)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -769,6 +771,7 @@ function util.add_ingredient(recipe_name, ingredient, quantity, options)
|
||||||
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)
|
||||||
|
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
|
||||||
end
|
end
|
||||||
|
|
@ -793,6 +796,7 @@ function util.add_ingredient_raw(recipe_name, ingredient, options)
|
||||||
if not should_force(options) and bypass(recipe_name) then return end
|
if not should_force(options) and bypass(recipe_name) then return end
|
||||||
if data.raw.recipe[recipe_name] and data.raw.item[ingredient.name] then
|
if data.raw.recipe[recipe_name] and data.raw.item[ingredient.name] then
|
||||||
me.add_modified(recipe_name)
|
me.add_modified(recipe_name)
|
||||||
|
prepare_redo_recycling(recipe_name)
|
||||||
add_ingredient_raw(data.raw.recipe[recipe_name], ingredient)
|
add_ingredient_raw(data.raw.recipe[recipe_name], ingredient)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -813,6 +817,7 @@ function util.set_ingredient(recipe_name, ingredient, quantity, options)
|
||||||
if not should_force(options) and bypass(recipe_name) then return end
|
if not should_force(options) and 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)
|
||||||
|
prepare_redo_recycling(recipe_name)
|
||||||
set_ingredient(data.raw.recipe[recipe_name], ingredient, quantity)
|
set_ingredient(data.raw.recipe[recipe_name], ingredient, quantity)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -902,6 +907,7 @@ function util.replace_ingredient(recipe_name, old, new, amount, multiply, option
|
||||||
if not should_force(options) and bypass(recipe_name) then return end
|
if not should_force(options) and 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)
|
||||||
|
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
|
||||||
end
|
end
|
||||||
|
|
@ -933,6 +939,7 @@ function util.remove_ingredient(recipe_name, old, options)
|
||||||
if not should_force(options) and bypass(recipe_name) then return end
|
if not should_force(options) and 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)
|
||||||
|
prepare_redo_recycling(recipe_name)
|
||||||
remove_ingredient(data.raw.recipe[recipe_name], old)
|
remove_ingredient(data.raw.recipe[recipe_name], old)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -958,6 +965,7 @@ function util.replace_some_product(recipe_name, old, old_amount, new, new_amount
|
||||||
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
|
||||||
me.add_modified(recipe_name)
|
me.add_modified(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
|
||||||
end
|
end
|
||||||
|
|
@ -987,6 +995,7 @@ function util.replace_some_ingredient(recipe_name, old, old_amount, new, new_amo
|
||||||
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)
|
||||||
|
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
|
||||||
end
|
end
|
||||||
|
|
@ -1012,6 +1021,7 @@ function util.set_product_probability(recipe_name, product, probability, options
|
||||||
if not should_force(options) and bypass(recipe_name) then return end
|
if not should_force(options) and 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)
|
||||||
|
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
|
||||||
end
|
end
|
||||||
|
|
@ -1033,6 +1043,7 @@ function util.set_product_amount(recipe_name, product, amount, options)
|
||||||
if not should_force(options) and bypass(recipe_name) then return end
|
if not should_force(options) and 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)
|
||||||
|
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
|
||||||
end
|
end
|
||||||
|
|
@ -1065,6 +1076,7 @@ function util.multiply_recipe(recipe_name, multiple, options)
|
||||||
if not should_force(options) and bypass(recipe_name) then return end
|
if not should_force(options) and 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)
|
||||||
|
prepare_redo_recycling(recipe_name)
|
||||||
multiply_recipe(data.raw.recipe[recipe_name], multiple)
|
multiply_recipe(data.raw.recipe[recipe_name], multiple)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -1131,6 +1143,7 @@ function util.remove_product(recipe_name, old, options)
|
||||||
if not should_force(options) and bypass(recipe_name) then return end
|
if not should_force(options) and 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)
|
||||||
|
prepare_redo_recycling(recipe_name)
|
||||||
remove_product(data.raw.recipe[recipe_name], old)
|
remove_product(data.raw.recipe[recipe_name], old)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -1209,6 +1222,7 @@ function util.set_recipe_time(recipe_name, time, options)
|
||||||
if not should_force(options) and bypass(recipe_name) then return end
|
if not should_force(options) and 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)
|
||||||
|
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
|
||||||
end
|
end
|
||||||
|
|
@ -1226,6 +1240,7 @@ function util.multiply_time(recipe_name, factor, options)
|
||||||
if not should_force(options) and bypass(recipe_name) then return end
|
if not should_force(options) and 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)
|
||||||
|
prepare_redo_recycling(recipe_name)
|
||||||
multiply_time(data.raw.recipe[recipe_name], factor)
|
multiply_time(data.raw.recipe[recipe_name], factor)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -1243,6 +1258,7 @@ function util.add_time(recipe_name, amount, options)
|
||||||
if not should_force(options) and bypass(recipe_name) then return end
|
if not should_force(options) and 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)
|
||||||
|
prepare_redo_recycling(recipe_name)
|
||||||
add_time(data.raw.recipe[recipe_name], amount)
|
add_time(data.raw.recipe[recipe_name], amount)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -1260,6 +1276,7 @@ function util.set_category(recipe_name, category, options)
|
||||||
if not should_force(options) and bypass(recipe_name) then return end
|
if not should_force(options) and 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)
|
||||||
|
prepare_redo_recycling(recipe_name)
|
||||||
data.raw.recipe[recipe_name].category = category
|
data.raw.recipe[recipe_name].category = category
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -1638,14 +1655,61 @@ function util.set_vtk_dcm_ingredients()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Recalculate recycling recipes, since our mod might make updates after quality generates them
|
-- Set correct number of outputs for recyclers
|
||||||
|
function util.size_recycler_output()
|
||||||
|
if data.raw.recipe["scrap-recycling"] and data.raw.recipe["scrap-recycling"].results then
|
||||||
|
for i, entity in pairs(data.raw.furnace) do
|
||||||
|
if util.contains(entity.crafting_categories, "recycling-or-hand-crafting") then
|
||||||
|
if entity.result_inventory_size < #data.raw.recipe["scrap-recycling"].results then
|
||||||
|
entity.result_inventory_size = #data.raw.recipe["scrap-recycling"].results
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
local most = 0
|
||||||
|
for i, recipe in pairs(data.raw.recipe) do
|
||||||
|
if data.raw.recipe.ingredients and #data.raw.recipe.ingredients > most then
|
||||||
|
most = #data.raw.recipe.ingredients
|
||||||
|
end
|
||||||
|
end
|
||||||
|
for i, entity in pairs(data.raw.furnace) do
|
||||||
|
if util.contains(entity.crafting_categories, "recycling-or-hand-crafting") then
|
||||||
|
if entity.result_inventory_size < most then
|
||||||
|
entity.result_inventory_size = most
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Save recycling metadata that is later removed by quality mod. Call near end of data.lua
|
||||||
|
function util.prepare_recycling_helper()
|
||||||
|
if mods.quality then
|
||||||
|
for _, recipe in pairs(data.raw.recipe) do
|
||||||
|
recipe.auto_recycle_helper = recipe.auto_recycle
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Recalculate recycling recipes, call near end of data-updates.lua, after calling
|
||||||
|
-- util.prepare_recycling_helper from data.lua
|
||||||
function util.redo_recycling()
|
function util.redo_recycling()
|
||||||
if mods.quality then
|
if mods.quality then
|
||||||
local recycling = require("__quality__.prototypes.recycling")
|
local recycling = require("__quality__.prototypes.recycling")
|
||||||
for _, recipe in pairs(data.raw.recipe) do
|
for _, recipe in pairs(data.raw.recipe) do
|
||||||
recycling.generate_recycling_recipe(recipe)
|
recipe.auto_recycle = recipe.auto_recycle_helper -- keeping this outside conditional to improve fidelity across multiple mods
|
||||||
|
if recipe.redo_recycling then
|
||||||
|
recycling.generate_recycling_recipe(recipe)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return util
|
|
||||||
|
|
||||||
|
-- Preps the recipe to have recycling recalculated. Expects the recipe exists.
|
||||||
|
function prepare_redo_recycling(recipe_name)
|
||||||
|
data.raw.recipe[recipe_name].redo_recycling = true
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
return util
|
||||||
|
|
|
||||||
3
data.lua
3
data.lua
|
|
@ -9,3 +9,6 @@ require("compatibility.data.hot-metals")
|
||||||
|
|
||||||
-- First part of hack for endgame combat
|
-- First part of hack for endgame combat
|
||||||
require("compatibility/titanium-endgame-combat-data")
|
require("compatibility/titanium-endgame-combat-data")
|
||||||
|
|
||||||
|
local util = require("data-util")
|
||||||
|
util.prepare_recycling_helper()
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "bztitanium",
|
"name": "bztitanium",
|
||||||
"version": "2.0.14",
|
"version": "2.0.15",
|
||||||
"factorio_version": "2.0",
|
"factorio_version": "2.0",
|
||||||
"title": "Titanium",
|
"title": "Titanium",
|
||||||
"author": "Brevven",
|
"author": "Brevven",
|
||||||
|
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
||||||
local util = require("__bztitanium__.data-util")
|
|
||||||
|
|
||||||
|
|
||||||
-- Set correct number of outputs for recyclers
|
|
||||||
for i, entity in pairs(data.raw.furnace) do
|
|
||||||
if util.contains(entity.crafting_categories, "recycling-or-hand-crafting") then
|
|
||||||
if entity.result_inventory_size < #data.raw.recipe["scrap-recycling"].results then
|
|
||||||
entity.result_inventory_size = #data.raw.recipe["scrap-recycling"].results
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue