#Runtime spoilage library - Factorio Mods

1 messages ยท Page 1 of 1 (latest)

fleet tiger
#

that looks so cool I just wish we could do things like half life so element decay into other elements

vital whale
#

@thin ingot maybe you wanna add a nuclear transmutation to your periodic madness some day ? :p

sand turtle
vital whale
#

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

sand turtle
#

Yeah, it still requires the DLC binary, so it cannot be the sole mechanic used to obtain something.

jaunty bison
#

What is the runtime overhead of this mod? Do you loop through all items every tick?

vital whale
#

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 :

  1. detect the event
  2. detect the type of inventory it's in
  3. replace with the right item
sand turtle
#

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?

vital whale
#

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.

thin ingot
#

i have a couple ideas so far

vital whale
#

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

vital whale
thin ingot
#

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 trianglepupper

vital whale
#

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)

gray slate
vital whale
#

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.

dim obsidianBOT
#

An API for working with items that spoil into multiple items

Author

LambdaLemon

Downloads

113

Factorio version

2.0

sand turtle
#

It was not runtime adjustable, but it worked before.

fair coyote
#

mmm interesting, it stores the items-to-spoil-to and probabilities in the effect name itself.

#

and a lot simpler runtime code...

vital whale
#

Well it doesn't do the same thing too.

fair coyote
#

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

vital whale
#

I mean, it's cool if you want to multiply items

#

But its entirely different of what I'm doing

fair coyote
#

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)?

vital whale
#

But it doesn't work

fair coyote
#

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.

vital whale
#

I just tried it with the given exemple

fair coyote
#

Just simpler and less feature-full.

#

oh

vital whale
#

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.

fair coyote
#

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.

fair coyote
vital whale
#

the item disappeared

#

In my V1, I was doing almost the same thing as this mod

fair coyote
#

elseif entity.type == "belt" then

#

lollll

#

should be transport-belt

vital whale
#

let me change that and try again

fair coyote
#

and splitter/loader?
Underground belts though... that won't work at all

vital whale
#

Yep. 2 issues :

  1. this mod does not do what it says it does (it's incomplete and probably WIP)
  2. 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"

fair coyote
#

๐Ÿ‘ ๐Ÿ‘

gray slate
fair coyote
#

yeah I definitely appreciate that RSL directly replaces the item wherever instead of just chucking the new things randomly in roughly the right place ๐Ÿ˜„

vital whale
#

I did that in the first place, but seeing items jumping around on belts annoyed me

fair coyote
vital whale
#

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)

gray slate
#

hm ok

sand turtle
vital whale
#

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

vital whale
fleet tiger
vital whale
fair coyote
#

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.

vital whale
#

yup I noticed this, kinda annoying

tall slate
#

Se arcospheres but now they spoil into each other too trianglepupper

vital whale
fleet tiger
#

that's exactly what I though

#

item that spoils in circle

#

with even 50% chance to spoil into something else

broken valley
#

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.