Modify Prototypes

Place to get help with not working mods / modding interface.
Drunkenseagull
Manual Inserter
Manual Inserter
Posts: 2
Joined: Thu Sep 08, 2016 3:42 pm
Contact:

Modify Prototypes

Post 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!
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5207
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Modify Prototypes

Post 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.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Post Reply

Return to “Modding help”