Page 1 of 1

I have idea for the mod and wonder about a spoilage mechanic.

Posted: Tue Dec 03, 2024 1:34 pm
by kocur4d
I have created a new ore: Probabilitium Ore!

Image

I wanted it to spoil into Iron Ore, Copper Ore, Coal or Stone with equal probability of 25%.

I have few more, great, ideas how player can create productions chains to skew those probabilities and so on.

But first I dont seem to be able to figure out if there is a way for an item to spoiled based on probability?

I think I can make a recipe that would have probabilistic outcome - and I plan to. But I think it would be such a cool mechanic if Probabilitium Ore spoiled on it own. I love Gleba!

When I checked the ItemPrototype docs for `spoil_result :: ItemID optional Requires Space Age to usenew` it only takes a single item id.

Is there a way for an item to spoil to something else based on probabilities?

Re: I have idea for the mod and wonder about a spoilage mechanic.

Posted: Tue Dec 03, 2024 6:44 pm
by gangerM
I haven't tried it myself, however the following chain of properties might allow you to set a function to be called, so you can do anything you want;
- spoil_to_trigger_result
-> trigger (Trigger)
--> TriggerEffectItem with an effect_id (string), I think a separate table for data:extend (data.lua) but I might be wrong and could be just the table you have to supply for the trigger field.
--> script.on_script_trigger_effect to use that effect_id (control.lua)
--> this script can create an item in the inventory of your player etc

edit; the links I used to look into it:
https://lua-api.factorio.com/latest/typ ... esult.html
https://lua-api.factorio.com/latest/typ ... tItem.html

Re: I have idea for the mod and wonder about a spoilage mechanic.

Posted: Tue Dec 03, 2024 6:56 pm
by s6x
Here is a mod doing something similar, so you have some code to look at.
https://mods.factorio.com/mod/multispoil

Re: I have idea for the mod and wonder about a spoilage mechanic.

Posted: Wed Dec 04, 2024 8:38 am
by kocur4d
Thank you! I will have a look.