What is the proper way to get a list of all qualities?

Place to get help with not working mods / modding interface.
Pikachar
Inserter
Inserter
Posts: 32
Joined: Wed Apr 19, 2023 9:16 pm
Contact:

What is the proper way to get a list of all qualities?

Post by Pikachar »

I'm currently working on a mod where I need to get a list of all of the qualities in the game. This should account for all the qualities added in the qualities mod/expansion and/or any that are from some random mod.

I looked into using data.raw["quality"][?] but I'm not really sure what would even go in the second part of that dictionary definition. Based on what I've seen in the documentation (https://lua-api.factorio.com/latest/types/Data.html) that's just going to end up specifying a specific quality/item/etc... and that's not quite what I want. I want an agnostic generic list of qualities without having to know specifically what's included.

Any and all help is appreciated!
Natha
Fast Inserter
Fast Inserter
Posts: 233
Joined: Sun Mar 15, 2015 1:48 pm
Contact:

Re: What is the proper way to get a list of all qualities?

Post by Natha »

data.raw["quality"] has all the qualities. Thats what you need
Pikachar
Inserter
Inserter
Posts: 32
Joined: Wed Apr 19, 2023 9:16 pm
Contact:

Re: What is the proper way to get a list of all qualities?

Post by Pikachar »

It seems I've forgotten a few things in my question. Mostly that data.raw cannot be accessed in the control stage. So, I need a way to obtain a list of all of the qualities that is accessible in the control stage. Not for modification purposes, but so I can create an appropriate reference list for some logic I need for my mod.
User avatar
gangerM
Burner Inserter
Burner Inserter
Posts: 18
Joined: Thu Nov 28, 2024 5:32 pm
Contact:

Re: What is the proper way to get a list of all qualities?

Post by gangerM »

prototypes.quality is what you want I think, it is a map from the name (string) to the LuaQualityPrototype.

https://lua-api.factorio.com/latest/cla ... otype.html
Pikachar
Inserter
Inserter
Posts: 32
Joined: Wed Apr 19, 2023 9:16 pm
Contact:

Re: What is the proper way to get a list of all qualities?

Post by Pikachar »

Awesome! That was exactly what I needed.
Post Reply

Return to “Modding help”