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

Place to get help with not working mods / modding interface.
kocur4d
Burner Inserter
Burner Inserter
Posts: 9
Joined: Fri Sep 02, 2016 1:15 pm
Contact:

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

Post 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?
User avatar
gangerM
Burner Inserter
Burner Inserter
Posts: 18
Joined: Thu Nov 28, 2024 5:32 pm
Contact:

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

Post 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
s6x
Inserter
Inserter
Posts: 34
Joined: Fri Nov 15, 2024 8:22 pm
Contact:

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

Post by s6x »

Here is a mod doing something similar, so you have some code to look at.
https://mods.factorio.com/mod/multispoil
kocur4d
Burner Inserter
Burner Inserter
Posts: 9
Joined: Fri Sep 02, 2016 1:15 pm
Contact:

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

Post by kocur4d »

Thank you! I will have a look.
Post Reply

Return to “Modding help”