For some applications, its useful to know the complete prototype hierarchy.
Some use cases: in factorio calculator apps or factoriomaps, if you want to get all the signals types: `item, fluid, virtual`, but if you just iterate over those three from `data.raw`, it will be far from complete. Currently, apart from `item`, you also have to iterate: `"ammo", "capsule", "gun", "item-with-entity-data", "item-with-label", "item-with-inventory", "blueprint-book", "item-with-tags", "selection-tool", "blueprint", "deconstruction-item", "module", "rail-planner", "tool", "armor", "mining-tool", "repair-tool"`.
Currently, the only way to obtain this list is to hardcode it into your mod, and manually update it for every version of the game, which is quite error prone.
It would be nice if there was a function that returned the complete prototype hierarchy similar to the one found on https://wiki.factorio.com/Prototype_definitions.
I'm not sure if there are any applications beyond the data stage, but in the data stage for sure it would be useful.
Get prototype tree (in data stage)
Re: Get prototype tree (in data stage)
All of that information can be gotten runtime through the Lua API: https://lua-api.factorio.com/latest/ for a given prototype type.
If you want to get ahold of me I'm almost always on Discord.
Re: Get prototype tree (in data stage)
How would I be able to determine if, for example, "ammo" (or lets say, artillery-shell), is a child of Prototype/Item? I can see that its of type "ammo", but nothing points me towards the fact that this is in fact an item and could be used as, for example, signalID.
The only way that I have been able to determine this is to hardcode a list of children of Prototype/Item for each version of the game. My goal is to do this in the data stage without the error prone process of hardcoding a list for each version of the game.
The only way that I have been able to determine this is to hardcode a list of children of Prototype/Item for each version of the game. My goal is to do this in the data stage without the error prone process of hardcoding a list for each version of the game.
Re: Get prototype tree (in data stage)
What is wrong with using the runtime stage game.item_prototypes ?L0laapk3 wrote: Fri Feb 15, 2019 7:13 pm How would I be able to determine if, for example, "ammo" (or lets say, artillery-shell), is a child of Prototype/Item? I can see that its of type "ammo", but nothing points me towards the fact that this is in fact an item and could be used as, for example, signalID.
The only way that I have been able to determine this is to hardcode a list of children of Prototype/Item for each version of the game. My goal is to do this in the data stage without the error prone process of hardcoding a list for each version of the game.
Re: Get prototype tree (in data stage)
I need information thats only available in the data stage: paths to textures.
Re: Get prototype tree (in data stage)
This (for the purpose of e.g. iterating through all item prototypes) was added as defines.prototypes some time ago.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.