Get prototype tree (in data stage)

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
L0laapk3
Inserter
Inserter
Posts: 25
Joined: Sun Mar 18, 2018 10:01 pm
Contact:

Get prototype tree (in data stage)

Post by L0laapk3 » Tue Feb 12, 2019 1:48 pm

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.

Rseding91
Factorio Staff
Factorio Staff
Posts: 8197
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Get prototype tree (in data stage)

Post by Rseding91 » Tue Feb 12, 2019 5:36 pm

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.

L0laapk3
Inserter
Inserter
Posts: 25
Joined: Sun Mar 18, 2018 10:01 pm
Contact:

Re: Get prototype tree (in data stage)

Post by L0laapk3 » 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.

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 3355
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: Get prototype tree (in data stage)

Post by Klonan » Fri Feb 15, 2019 7:27 pm

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.
What is wrong with using the runtime stage game.item_prototypes ?

L0laapk3
Inserter
Inserter
Posts: 25
Joined: Sun Mar 18, 2018 10:01 pm
Contact:

Re: Get prototype tree (in data stage)

Post by L0laapk3 » Fri Feb 15, 2019 8:06 pm

I need information thats only available in the data stage: paths to textures.

Post Reply

Return to “Modding interface requests”

Who is online

Users browsing this forum: No registered users and 1 guest