I'm looking for a way to store some data on an entity itself. I need this data to persist even if the item is mined.
I was told the only way of achieving this is using something like http://afforess.github.io/Factorio-Stdl ... ntity.html to store the data "outside" the entity. Then I found https://wiki.factorio.com/Prototype/ItemWithEntityData, which by it's name implies the functionality I need. But I don't see anything in the definition that allows me to persist data per-entity as well as per-item.
Is this the prototype I am looking for or am I barking up the wrong tree?
Please explain to me: Prototype/ItemWithEntityData
- adamwong246
- Fast Inserter
- Posts: 148
- Joined: Tue Dec 01, 2020 5:01 am
- Contact:
Re: Please explain to me: Prototype/ItemWithEntityData
So on the first look it seems to me, that this is what you search. But the problem could be, that you can only use the keys, represented on the wiki. At least I don't know, how to add some. I was told, that this isn't possible.
I store additional data also in a seperate table, using the position data of the entity. this is of course not persistant over Item mining, but you could use another unique number.
So if you don't need anothe key's than they in the Prototype, it could be yours. otherwise I don't know.
I store additional data also in a seperate table, using the position data of the entity. this is of course not persistant over Item mining, but you could use another unique number.
So if you don't need anothe key's than they in the Prototype, it could be yours. otherwise I don't know.
Re: Please explain to me: Prototype/ItemWithEntityData
ItemWithEntityData is poorly named, it is only designed to support vehicles.
What you really want is ItemWithTags. This has a control.lua stack.tags property that allows you to store arbitrary data.
There is no entity.tags property (well there is, but only to help copy blueprint tags from ghosts). So you have to store entity data in an external table. The best practice is to index this table with entity.unit_number.
What you really want is ItemWithTags. This has a control.lua stack.tags property that allows you to store arbitrary data.
There is no entity.tags property (well there is, but only to help copy blueprint tags from ghosts). So you have to store entity data in an external table. The best practice is to index this table with entity.unit_number.