Allow spoil_result to spoil into multiple weighted items

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
lambdalemon
Burner Inserter
Burner Inserter
Posts: 6
Joined: Wed Oct 23, 2024 12:03 pm
Contact:

Allow spoil_result to spoil into multiple weighted items

Post by lambdalemon »

Allow items to spoil into multiple items using a weighted value. And also only allow the item to spoil into one item at a time.

Code: Select all

data.raw["item"]["iron-plate"].spoil_result = {
	{
		name = "copper-ore",
		weight = 1
	},
	{
		name = "iron-ore",
		weight = 99
	}
}
Puke
Burner Inserter
Burner Inserter
Posts: 5
Joined: Mon Jun 13, 2016 7:00 pm
Contact:

Re: Allow spoil_result to spoil into multiple weighted items

Post by Puke »

+1 to that
Currently, you can have multiple "spoil_result" for an item. Each spoil result can have a probability to happen.
But there is no way I'm aware of to make these results mutually exclusive.

Using the scripting option (spoil_to_trigger) can allow to make this possible, but runs into a wall as soon as the item spoils on a belt (because the item disappears first, then the script triggers, so you cannot replace it where it was on the belt).
Plus, scripting it may have a huge performance impact.
Xorimuth
Filter Inserter
Filter Inserter
Posts: 708
Joined: Sat Mar 02, 2019 9:39 pm
Contact:

Re: Allow spoil_result to spoil into multiple weighted items

Post by Xorimuth »

Puke wrote: Thu Dec 05, 2024 10:17 am Currently, you can have multiple "spoil_result" for an item. Each spoil result can have a probability to happen.
Nope, currently you can only specify a single spoil_result, unless you do more complex shenanigans with spoil_to_trigger_result.
My mods
Content: Lunar Landings | Freight Forwarding | Spidertron Patrols | Spidertron Enhancements | Power Overload
QoL: Factory Search | Module Inserter Simplified | Wire Shortcuts X | Ghost Warnings
Puke
Burner Inserter
Burner Inserter
Posts: 5
Joined: Mon Jun 13, 2016 7:00 pm
Contact:

Re: Allow spoil_result to spoil into multiple weighted items

Post by Puke »

That is indeed what I did, I was pretty sure I just tried putting a list of strings, but looking back at the code, I used the insert_item trigger with two items.

Still ! Have the ability to mod multiple results which could be mutually exclusive or not would be nice, in order to be able to spoil in place on a belt simply for instance.
protocol_1903
Fast Inserter
Fast Inserter
Posts: 133
Joined: Fri Sep 09, 2022 4:33 pm
Contact:

Re: Allow spoil_result to spoil into multiple weighted items

Post by protocol_1903 »

+1, this would be interesting for uranium and nuclear mods modeling half-lives. Imagine that each u-235 has a 50% chance to become whatever u235 decays into, and a 50% chance to stay as u235. That would be so cool.
If you need to reach me, message me on discord.

I make qol mods. Check them out, maybe.
https://mods.factorio.com/user/protocol_1903
If you have a mod idea, I can look into it.
MacFeejj
Manual Inserter
Manual Inserter
Posts: 3
Joined: Mon Apr 24, 2023 9:23 am
Contact:

Re: Allow spoil_result to spoil into multiple weighted items

Post by MacFeejj »

This is a nice idea, but technically it'd raise a _lot_ of implementation issues. Currently, one stack of items will always spoil into one stack of items - if a stack spoils while an inserter is moving it, or in a container with limited size, or while being carried in a rocket, it'll spoil into exactly one stack replacing the one already there - if one stack of items could spoil into multiple stacks, that would raise a _lot_ of issues. The only sane way I can see this working is if each stack spoils into the same item, which, while averaging out into the same result, would be quite janky.
protocol_1903
Fast Inserter
Fast Inserter
Posts: 133
Joined: Fri Sep 09, 2022 4:33 pm
Contact:

Re: Allow spoil_result to spoil into multiple weighted items

Post by protocol_1903 »

MacFeejj wrote: Thu Dec 05, 2024 9:31 pm This is a nice idea, but technically it'd raise a _lot_ of implementation issues. Currently, one stack of items will always spoil into one stack of items - if a stack spoils while an inserter is moving it, or in a container with limited size, or while being carried in a rocket, it'll spoil into exactly one stack replacing the one already there - if one stack of items could spoil into multiple stacks, that would raise a _lot_ of issues. The only sane way I can see this working is if each stack spoils into the same item, which, while averaging out into the same result, would be quite janky.
It wouldn't really be that janky. When combining items into a stack, the spoilage time is averaged, so it's already "janky" by your definition. Making the whole stack spoil into the same item based on the defined weights would be no less jank, and still makes sense.
If you need to reach me, message me on discord.

I make qol mods. Check them out, maybe.
https://mods.factorio.com/user/protocol_1903
If you have a mod idea, I can look into it.
Post Reply

Return to “Modding interface requests”