recycling/fulgora rework
This commit is contained in:
parent
9be9a1e545
commit
30e095a958
12 changed files with 230 additions and 14 deletions
66
alloy-separation.lua
Normal file
66
alloy-separation.lua
Normal file
|
@ -0,0 +1,66 @@
|
|||
local util = require("data-util");
|
||||
local recycling = require("__quality__.prototypes.recycling")
|
||||
|
||||
if mods["space-age"] then
|
||||
|
||||
function recipe_is_separable(recipe)
|
||||
for _, category in pairs(not_separable) do
|
||||
if recipe.category == category then return false end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
function generate_alloy_separation_recipe(alloy, recipe)
|
||||
local result =
|
||||
{
|
||||
type = "recipe",
|
||||
subgroup = "alloy-separation",
|
||||
category = "recycling"
|
||||
}
|
||||
|
||||
if recipe.result or recipe.results then
|
||||
if not add_recipe_values(result, recipe, result) then return end
|
||||
end
|
||||
|
||||
if result.name then
|
||||
-- We (re)generate the self-recycling recipe, because we need it until the tech is discovered
|
||||
recycling.generate_self_recycling_recipe(data.raw.item[alloy])
|
||||
|
||||
result.name = result.name.."-separation"
|
||||
result.enabled = false
|
||||
result.hidden = false
|
||||
result.hide_from_player_crafting = true
|
||||
result.energy_required = 5 * result.energy_required / util.get_amount(recipe.name, alloy)
|
||||
result.localised_name = {"recipe-name.separation", {"item-name."..alloy}}
|
||||
data.raw.recipe[result.name] = result
|
||||
util.add_unlock("alloy-separation", result.name)
|
||||
end
|
||||
end
|
||||
|
||||
for _, alloy in pairs(alloys_to_separate) do
|
||||
if data.raw.item[alloy] then
|
||||
local fewest_fluids = 100
|
||||
local best_recipe = ""
|
||||
for _, recipe in pairs(data.raw.recipe) do
|
||||
if util.get_amount(recipe.name, alloy) > 0 and recipe_is_separable(recipe) then
|
||||
local fluids = 0
|
||||
if recipe.ingredients then
|
||||
for _, ingredient in pairs(recipe.ingredients) do
|
||||
if ingredient.type == "fluid" then fluids = fluids + 1 end
|
||||
end
|
||||
end
|
||||
if fluids < fewest_fluids then
|
||||
fewest_fluids = fluids
|
||||
best_recipe = recipe
|
||||
end
|
||||
end
|
||||
end
|
||||
-- TODO: If there are fluids in the recipe, create a fake recipe without fluids, generate the separation recipe, and then remove it
|
||||
if best_recipe then
|
||||
-- log("Creating alloy separation recipe for "..best_recipe.name.." with category "..(best_recipe.category or "nil"))
|
||||
generate_alloy_separation_recipe(alloy, best_recipe)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
|
@ -1,6 +1,26 @@
|
|||
---------------------------------------------------------------------------------------------------
|
||||
Version: 2.1.1
|
||||
Date: 2025-01-17
|
||||
Changes:
|
||||
- Fix load issues with some mod settings and loadouts introduced last version
|
||||
---------------------------------------------------------------------------------------------------
|
||||
Version: 2.1.0
|
||||
Date: 2025-01-17
|
||||
Changes:
|
||||
- Space Age: Add new "Alloy separation" technology that allows recycling of some alloys,
|
||||
including solder and bronze. These alloys will only self-recycle at first, but researching
|
||||
the new tech will unlock a recycling recipe that breaks them down into components.
|
||||
- Space Age: Tinned cable is always enabled (mostly affects combinator and pumpjack recipes)
|
||||
Scrap recycling now produces tinned cable instead of copper cable, at 4x the rate.
|
||||
This will almost certainly require some adjustment on Fulgora, but will be a buff to tin
|
||||
production on Fulgora, without nerfing copper production.
|
||||
- Space Age: When bronze plate is enabled, Fulgoran ruins now hold some.
|
||||
- Space Age: Big Fulgora rocks now have some tin ore (and if Lead mod is enabled, lead ore) to
|
||||
help kickstart production before solder can be recycled.
|
||||
- Space Age / Any Planet Start: Scrap recycling no longer produces bronze plates
|
||||
---------------------------------------------------------------------------------------------------
|
||||
Version: 2.0.6
|
||||
Date: 2025-01-07
|
||||
Date: 2025-01-14
|
||||
Fixes:
|
||||
- Working with Asteroid Mining mod
|
||||
---------------------------------------------------------------------------------------------------
|
||||
|
|
69
control.lua
69
control.lua
|
@ -7,3 +7,72 @@ util.add_regenerate_command_handler()
|
|||
util.add_list_command_handler()
|
||||
|
||||
util.warptorio2_expansion_helper()
|
||||
|
||||
function update_recycling_on_research(event)
|
||||
if event.research.name == "alloy-separation" then
|
||||
update_recycling(event.research.force)
|
||||
end
|
||||
end
|
||||
script.on_event(defines.events.on_research_finished, update_recycling_on_research)
|
||||
|
||||
function update_recycling_on_reset(event)
|
||||
update_recycling(event.force)
|
||||
end
|
||||
script.on_event(defines.events.on_technology_effects_reset, update_recycling_on_reset)
|
||||
|
||||
function update_recycling(force)
|
||||
if not force.technologies["alloy-separation"].researched then
|
||||
-- In this case the player is probably trying to unresearch the tech, and we should fix
|
||||
-- recipes as would be expected in this case
|
||||
for _, recipe in pairs(force.recipes) do
|
||||
if force.recipes[recipe.name.."-separation"] then
|
||||
force.recipes[recipe.name].enabled = true
|
||||
force.recipes[recipe.name.."-separation"].enabled = false
|
||||
end
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
-- disable self recycling, and ensure separation is enabled
|
||||
for _, recipe in pairs(force.recipes) do
|
||||
if force.recipes[recipe.name.."-separation"] then
|
||||
force.recipes[recipe.name].enabled = false
|
||||
force.recipes[recipe.name.."-separation"].enabled = true
|
||||
end
|
||||
end
|
||||
|
||||
-- make sure any entities doing old recipe can update to new one next tick
|
||||
for _, surface in pairs(game.surfaces) do
|
||||
for _, entity in pairs(surface.find_entities_filtered(
|
||||
{type="furnace", force=force.name})) do
|
||||
local recipe = entity.get_recipe()
|
||||
if recipe then
|
||||
if recipe.name:match("-recycling") then
|
||||
local newr = recipe.name.."-separation"
|
||||
if entity.force.recipes[newr] and entity.force.recipes[newr].enabled then
|
||||
local item = recipe.name:gsub("-recycling", "")
|
||||
-- mark the craft as finished and clear recycler inventory, to give the furnace-type
|
||||
-- a chance to reset its recipe to the newly available recipe
|
||||
entity.crafting_progress = 1
|
||||
entity.get_inventory(defines.inventory.furnace_source).clear()
|
||||
-- clear inserting inserters hands, giving an extra swing to reset recipes, just in case
|
||||
for _, inserter in pairs(surface.find_entities_filtered(
|
||||
{type={"inserter"}, position=entity.position, radius=5})) do
|
||||
if inserter.held_stack.valid_for_read and inserter.held_stack.name == item then
|
||||
inserter.held_stack.clear()
|
||||
end
|
||||
end
|
||||
-- clear all items in nearby input loaders,
|
||||
-- Overshoots, but with loaders it's harder to be precise
|
||||
for _, loader in pairs(surface.find_entities_filtered(
|
||||
{type={"loader"}, position=entity.position, radius=5})) do
|
||||
if loader.loader_type == "input" then
|
||||
loader.clear_items_inside()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
require("alloy-separation")
|
||||
require("tin-recipe-final-stacking")
|
||||
-- require("tin-recipe-final-5d")
|
||||
require("tin-recipe-final-rrr")
|
||||
|
|
|
@ -13,12 +13,18 @@ if mods.Asteroid_Mining and not data.raw.item["asteroid-tin-ore"] then
|
|||
util.addtype("tin-ore", {a = 0,r = 0.55,g = 0.45,b = 0.3})
|
||||
end
|
||||
|
||||
if mods["any-planet-start"] and util.me.get_setting("aps-planet") == "fulgora" then
|
||||
-- In order to craft the first recycler, if bronze is enabled
|
||||
util.add_product("scrap-recycling", util.item("bronze-plate", 1, 0.01))
|
||||
util.set_product_amount("recycler", "bronze-plate", 2)
|
||||
end
|
||||
util.redo_recycling()
|
||||
|
||||
-- Helps with fulgora clean starts
|
||||
util.add_minable_result("simple-entity", "fulgoran-ruin-vault", {type="item", name="bronze-plate", amount_min=79, amount_max=103})
|
||||
util.add_minable_result("simple-entity", "fulgoran-ruin-colossal", {type="item", name="bronze-plate", amount_min=15, amount_max=40})
|
||||
util.add_minable_result("simple-entity", "fulgoran-ruin-huge", {type="item", name="bronze-plate", amount_min=7, amount_max=31})
|
||||
util.add_minable_result("simple-entity", "fulgoran-ruin-big", {type="item", name="bronze-plate", amount_min=7, amount_max=15})
|
||||
util.add_minable_result("simple-entity", "fulgoran-ruin-stonehenge", {type="item", name="bronze-plate", amount_min=7, amount_max=13})
|
||||
util.add_minable_result("simple-entity", "fulgoran-ruin-medium", {type="item", name="bronze-plate", amount_min=1, amount_max=7})
|
||||
util.add_minable_result("simple-entity", "fulgoran-ruin-small", {type="item", name="bronze-plate", amount_min=0, amount_max=2})
|
||||
|
||||
util.add_minable_result("simple-entity", "big-fulgora-rock", {type="item", name="tin-ore", amount_min=10, amount_max=22})
|
||||
util.add_minable_result("simple-entity", "big-fulgora-rock", {type="item", name="lead-ore", amount_min=10, amount_max=22})
|
||||
-- Must be last
|
||||
util.create_list()
|
||||
|
|
|
@ -912,14 +912,20 @@ function util.get_ingredient_amount(recipe_name, ingredient_name)
|
|||
return 0
|
||||
end
|
||||
|
||||
-- Get the amount of the result
|
||||
-- Get the amount of the result (currently ignores probability)
|
||||
function util.get_amount(recipe_name, product)
|
||||
if not product then product = recipe_name end
|
||||
local recipe = data.raw.recipe[recipe_name]
|
||||
if recipe then
|
||||
if recipe.results then
|
||||
for i, result in pairs(recipe.results) do
|
||||
if result.name == product then return result.amount end
|
||||
if result.name == product then
|
||||
if result.amount then
|
||||
return result.amount
|
||||
elseif result.amount_min then
|
||||
return (result.amount_min + result.amount_max) / 2
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return 0
|
||||
|
@ -944,7 +950,7 @@ end
|
|||
-- Use amount to set an amount. If that amount is a multiplier instead of an exact amount, set multiply true.
|
||||
function util.replace_ingredient(recipe_name, old, new, amount, multiply, options)
|
||||
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]) and (data.raw.item[old] or data.raw.fluid[old]) then
|
||||
me.add_modified(recipe_name)
|
||||
prepare_redo_recycling(recipe_name)
|
||||
replace_ingredient(data.raw.recipe[recipe_name], old, new, amount, multiply)
|
||||
|
@ -1513,7 +1519,7 @@ end
|
|||
|
||||
-- Adds a result to a mineable type
|
||||
function util.add_minable_result(t, name, result)
|
||||
if data.raw[t] and data.raw[t][name] and data.raw[t][name].minable then
|
||||
if data.raw[t] and data.raw[t][name] and data.raw[t][name].minable and data.raw.item[result.name] then
|
||||
if data.raw[t][name].minable.result and not data.raw[t][name].minable.results then
|
||||
data.raw[t][name].minable.results = {
|
||||
util.item(data.raw[t][name].minable.result ,data.raw[t][name].minable.count)}
|
||||
|
|
14
data.lua
14
data.lua
|
@ -9,6 +9,20 @@ local util = require("data-util");
|
|||
|
||||
util.prepare_recycling_helper()
|
||||
|
||||
-- Global to determine which alloys to provide separation (recycling) recipes for
|
||||
alloys_to_separate = {
|
||||
"solder",
|
||||
"bronze-plate",
|
||||
"zircaloy-4",
|
||||
"lead-lithium-eutectic",
|
||||
}
|
||||
-- Global of which recipe categories should not be treated as separable
|
||||
-- (Things like metallurgy, chemistry, smelting should all be treated as separable)
|
||||
not_separable = {
|
||||
"recycling", "recycling-or-hand-crafting",
|
||||
"stacking", "crating",
|
||||
}
|
||||
|
||||
|
||||
-- Must be last
|
||||
util.create_list()
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "bztin",
|
||||
"version": "2.0.6",
|
||||
"version": "2.1.1",
|
||||
"factorio_version": "2.0",
|
||||
"title": "Tin",
|
||||
"author": "Brevven",
|
||||
|
|
|
@ -31,10 +31,12 @@ organotin-chemistry=Organotin chemistry
|
|||
tin-matter-processing=Tin conversion
|
||||
glassmaking=Glassmaking
|
||||
solder=__ITEM__solder__
|
||||
alloy-separation=Alloy separation
|
||||
|
||||
[technology-description]
|
||||
tinned-cable=Tinned copper cables to prevent corrosion
|
||||
organotin-chemistry=Toxic compounds often used to stabilize plastics
|
||||
alloy-separation=With chemistry, heat, and magnetism we can now separate some alloys into their constituent metals.
|
||||
|
||||
[recipe-name]
|
||||
alumina=__ITEM__alumina__
|
||||
|
@ -51,6 +53,7 @@ casting-solder=Casting solder
|
|||
jellyskin-processing=Jellyskin processing
|
||||
tin-from-organotins=Tin from organotins
|
||||
metallic-asteroid-crushing-tin=Metallic asteroid crushing for tin
|
||||
separation=__1__ separation
|
||||
|
||||
[recipe-description]
|
||||
tin-sulfides=Only possible on Vulcanus, extract tin from the released acidic gases.
|
||||
|
@ -70,6 +73,6 @@ bztin-recipe-bypass=Skip modifying these recipes (comma-separated list).
|
|||
bztin-list=If enabled, the text command [color=orange]/bz-list[/color] will dump a file to the script-output directory with a full list of recipes modified.\nRecommended to turn this off after you are done configuring your other settings.
|
||||
|
||||
[string-mod-setting]
|
||||
bztin-more-intermediates-no=No
|
||||
bztin-more-intermediates-cable=Yes: Only tinned cable
|
||||
bztin-more-intermediates-no=No (Ignored in Space Age)
|
||||
bztin-more-intermediates-cable=Yes: Only tinned cable (Tinned cable is always enabled in Space Age)
|
||||
bztin-more-intermediates-bronze=Yes: Tinned cable & Bronze
|
||||
|
|
1
me.lua
1
me.lua
|
@ -12,6 +12,7 @@ me.recipes = {"tin-plate", "solder", "organotins",
|
|||
|
||||
|
||||
function me.use_cable()
|
||||
if mods["space-age"] then return true end
|
||||
if me.get_setting("bz-all-intermediates") then return true end
|
||||
return me.get_setting("bztin-more-intermediates") == "cable" or me.use_bronze()
|
||||
end
|
||||
|
|
|
@ -9,6 +9,12 @@ else
|
|||
util.add_product("scrap-recycling", util.item("solder", 1, .01))
|
||||
end
|
||||
|
||||
if mods["space-age"] then
|
||||
util.replace_product("scrap-recycling", "copper-cable", "tinned-cable")
|
||||
util.set_product_probability("scrap-recycling", "tinned-cable", 0.12)
|
||||
util.add_to_ingredient("tinned-cable", "tin-plate", 1)
|
||||
end
|
||||
|
||||
if mods.bztitanium then
|
||||
util.replace_ingredient("superconductor", "titanium-plate", "tin-plate")
|
||||
else
|
||||
|
|
|
@ -106,6 +106,31 @@ data:extend({
|
|||
results = {{type = "item", name = "solder", amount = 40}},
|
||||
allow_productivity = true
|
||||
},
|
||||
{
|
||||
type = "item-subgroup",
|
||||
name = "alloy-separation",
|
||||
group = "intermediate-products",
|
||||
},
|
||||
{
|
||||
type = "technology",
|
||||
name = "alloy-separation",
|
||||
icons = {
|
||||
{icon = "__bztin__/graphics/icons/solder.png", icon_size = 128, scale = 0.33, shift = {0,-6}},
|
||||
{icon = "__bztin__/graphics/icons/tin-plate.png", icon_size = 128, scale = 0.25, shift = {-6,4}},
|
||||
mods.bzlead and {icon = "__bzlead__/graphics/icons/lead-plate.png", icon_size = 64, scale = 0.5, shift = {6,4}} or
|
||||
{icon = "__base__/graphics/icons/copper-plate.png", icon_size = 64, scale = 0.5, shift = {6,4}},
|
||||
},
|
||||
effects = {},
|
||||
prerequisites = {"metallurgic-science-pack", "electromagnetic-science-pack"},
|
||||
unit = {
|
||||
count = 250, time = 30,
|
||||
ingredients = {
|
||||
{"chemical-science-pack", 1},
|
||||
{"electromagnetic-science-pack", 1},
|
||||
{"metallurgic-science-pack", 1},
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
util.add_effect("foundry", { type = "unlock-recipe", recipe = "casting-solder" })
|
||||
end
|
||||
|
@ -528,4 +553,3 @@ data:extend({
|
|||
util.add_unlock("space-platform-thruster", "metallic-asteroid-crushing-tin")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue