#Runtime spoilage library - Factorio Mods
1 messages ยท Page 1 of 1 (latest)
that looks so cool I just wish we could do things like half life so element decay into other elements
Well with this mod you can
This is one of the goals of this mod.
I need to clarify the features, if you did not get that by reading my description ๐ญ
@thin ingot maybe you wanna add a nuclear transmutation to your periodic madness some day ? :p
Pretty sure spoilage will require the DLC, unless you made a spoilage system that works without in-game spoilage timers?
It requires the spoilage feature, which is available from the DLC binary without loading he mod "space age".
The goal of doing it like this is to allow people to make complete overhauls without loading the space age planets and recipes
Yeah, it still requires the DLC binary, so it cannot be the sole mechanic used to obtain something.
What is the runtime overhead of this mod? Do you loop through all items every tick?
No. Each item that uses RSL to determine its outcome fires a script event.
This tool doesn't make all items have random results. You must tell the library what results you want to allow for what item.
I detect this event and call the appropriate functions.
The steps are :
- detect the event
- detect the type of inventory it's in
- replace with the right item
Yeah, it sounds like the overhead should be minimal, it just fires a function on spoilage and the function does whatever you tell it to do?
that's about right
there can be optimizations tho, but I decided to not implement them just yet. For instance, each item that spoils will fire the event EVEN if the item is inside a stack (and as you know, when an item spoils, the whole stack spoils)
I could filter out events that target an entity that was already affected during a certain tick, but I'm not sure the gain in performance would be significant.
When I tried it out, I made iron plates spoilable in my SA save. When I fired up the game, after a few seconds, all my iron plates everywhere spoiled into a random outcome at the same time. The game dipped to 58 - 50 UPS during a second (keep in mind that was all the thousands of iron plates everywhere on all surfaces spoiling at the same tick)
I tested it in the lab using many belts and inifinitychests and the UPS didn't budge.
oh i probably will
i have a couple ideas so far
I also think I forgot to include a function to handle the case where an item spoils inside a rocket pod / cargo pod. I don't know if they can spoil when they are in a cargo pod tho
If you include isotopes, markov chains and transmutation, Factorio will become a torture chamber
oh, i plan to have every singe decay chain
the main idea is having 3 buildings that can decay the item into it into that decay tree (alpha, beta, gamma)
so anything can become lead 
I made this mod to allow myself to create unstable items that can spoil into B or C, and so on. The basic idea is that you'd really want B and not C, but it elvolved into "what if you want a little bit of both and all the possible outcomes can be useful ?".
The idea of conditional results came along the way... because why not being able to create items only if come temporary conditions are met ?
By the way, the function isn't in the code yet, but it's also possible to create an item based on the position of a trigger in some container (minecraft style)
you could do this already, just having an item with a 50% chance of decaying into itself or into the decayed state
Using spoilage ?
Cuz spoil_result doesn't accept probabilities. It's a fixed result.
What I do is only possible since a recent update that allows to have both spoil_result and spoil_to_trigger result at the same time.
Otherwise, you'd need a recipe to achieve what have been described. Spoilage couldn't do it.
It was not runtime adjustable, but it worked before.
mmm interesting, it stores the items-to-spoil-to and probabilities in the effect name itself.
and a lot simpler runtime code...
Well it doesn't do the same thing too.
rather than iterate through the belt transport lines, it just does a spill_item_stack at the event's source_position
loses quality info too though
since you'd need spoil_result for that
I mean, it's cool if you want to multiply items
But its entirely different of what I'm doing
sure the mechanism is very different. But for people who just want an item to spoil into a random other item(s), it is probably a better solution (except for the quality caveat)?
But it doesn't work
What do you mean? I've been looked at the code for "Multi-spoil" and it looks fine.
It is a library to provide that functionality, like yours.
I just tried it with the given exemple
and it did not work for belts
The whole reason why I built a library in the first place was handling the case of belts.
The code looks ok though, although I suspect the items may not stay in the same lane, they might jump around a bit, idk. And if an item spoils into multiple, some of them may not land on the belt I suspect.
What happened?
oh
elseif entity.type == "belt" then
lollll
should be transport-belt
let me change that and try again
and splitter/loader?
Underground belts though... that won't work at all
Yep. 2 issues :
- this mod does not do what it says it does (it's incomplete and probably WIP)
- my point was : it doesn't do what I do at all, nor does it try to. And it's not a matter of feature. I do actively make sure that the item that spoils is replaced by something by targeting it directly.
Before being able to use spoil_result and spoil_to_trigger result, this wasn't possible, because when an item spoils, it's deleted from the game. So you cannot know where exactly it was without a placeholder.
IMO, there is a difference between "creating a random item inside or near the entity where an item has spoiled" and "replacing a item that spoiled by a random other item"
๐ ๐
no, just spoil_to_trigger then do the probability bits manually
yeah I definitely appreciate that RSL directly replaces the item wherever instead of just chucking the new things randomly in roughly the right place ๐
I did that in the first place, but seeing items jumping around on belts annoyed me
yeah, that's how Multi-spoil works but it is impossible to get a 'perfect' solution that way, especially for belts.
The first things I tried was to have multiple triggers, and use the "probability" key. But ... they arent exclusive...
So... I could end up having items making babies.
(which is fun, by the way, and can totally become a feature)
hm ok
Cursed mod idea: if a chest has two of the same item, they can multiply
And yeah in the beginning, my code was pretty much as simple as "multi spoil"
Until I realized there were so many different types of inventories... and so many caveats to make the thing be seemless for the player
I know you meant multiply the items. But you could push it further : multiply the chest.
no I'm sorry I did not read the description only the videos because I am tired ^^
By the way, for now, for the sake of optimization, and if nobody cares about it, it will not respect the stack position if it deems "it doesn't matter" (in containers like chests). It only respects the precise position when it matters (belts, underground, splitters, the ground...)
that's probably an improvement lol
in vanilla, you get chests fill up with a few items of spoilage in each slot.
Because the stacks of spoilage don't combine when they spoil.
yup I noticed this, kinda annoying
Se arcospheres but now they spoil into each other too 
Eheh, I thought about it.
There can definetly be systems like that.
Imagine the amount of chaos.
That being said, you could just make them spoil in a certain chain order without needing any runtime shenanigan if you dont want to randomize the outcome. That would already be pretty chaotic.
that's exactly what I though
item that spoils in circle
with even 50% chance to spoil into something else
How complicated is it to implement these kinds of spoil functions?
I really like the idea and want to make an item or two spoil into special components on conditions, however there are only 2 instances where I would want to do this atm. (During thunderstorm and one at night)
I am also trying to avoid dependencies however I accept I might have to have this mod as a dependent to make this happne.