Page 1 of 1

Modify Prototypes

Posted: Sat Oct 05, 2019 8:35 pm
by Drunkenseagull
Hey, I want to add new variables to entities and items to work with. These values need to be preserved for the thing's entire life, from item to entity and back, and when stacked in an inventory.

Just went through the modding tutorial so I'm pretty new; ways I'm thinking this would have to be done are:

A: Add new variables to the prototype that all the things I want to affect inherit from.
B: Check all prototypes after they are created and if they are of type x or y or z, add the new variables to them.

I'm not sure which loading stage these could/should be done at either?

Thanks for any help!

Re: Modify Prototypes

Posted: Sat Oct 05, 2019 10:37 pm
by eradicator
General advice: Describe what you're trying to implement instead of asking for what you think is the best solution. Because if you're new then a) what you're thinking of is *not* the best solution and b) there's no point in keeping it secret, someone else probably thought of it.

You probably want https://wiki.factorio.com/Prototype/ItemWithTags and then manage the data yourself in control.lua. No idea how that works with stackable items. Factorissimo 2 uses this for the factory items i think.