How to add Custom Field to prototypes?

Place to get help with not working mods / modding interface.
ArsStels
Burner Inserter
Burner Inserter
Posts: 10
Joined: Sat Aug 21, 2021 2:28 am
Contact:

How to add Custom Field to prototypes?

Post by ArsStels »

Is it possible to add a new field to the prototype that can be interacted with in runtime? I have a great idea for a mod, but I'm running into this limitation. And I don't want to do everything through runtime, because it will be even more difficult to work with the implementation of new things. I have almost no plans to add new buildings. The only ideas are to add new mechanics that require intervention in the prototypes of buildings that consume electricity. Or its producer. Generators.
Rseding91
Factorio Staff
Factorio Staff
Posts: 15495
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: How to add Custom Field to prototypes?

Post by Rseding91 »

It is not. You can access prototypes values runtime through the prototypes object.
If you want to get ahold of me I'm almost always on Discord.
ArsStels
Burner Inserter
Burner Inserter
Posts: 10
Joined: Sat Aug 21, 2021 2:28 am
Contact:

Re: How to add Custom Field to prototypes?

Post by ArsStels »

Rseding91 wrote: Wed Apr 30, 2025 10:53 am It is not. You can access prototypes values runtime through the prototypes object.
Please tell me how to do this then? For example, add a new field for the assembly machine.

Basically, I just need to add a new property to buildings, display it as speed or power consumption near the mouse or under the map as information.Well, and based on this data, interact with buildings differently.
Rseding91
Factorio Staff
Factorio Staff
Posts: 15495
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: How to add Custom Field to prototypes?

Post by Rseding91 »

It is not possible to add new fields to prototypes.
If you want to get ahold of me I'm almost always on Discord.
User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3745
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: How to add Custom Field to prototypes?

Post by DaveMcW »

The way most mods do it is create a storage.custom_fields table in control.lua that maps entities to custom fields.

You then need to update the table whenever an entity is built or destroyed.
Post Reply

Return to “Modding help”