Specify meaning of alternative numbered key "tuple"s for struct types

Post Reply
sparr
Smart Inserter
Smart Inserter
Posts: 1327
Joined: Fri Feb 14, 2014 5:52 pm
Contact:

Specify meaning of alternative numbered key "tuple"s for struct types

Post by sparr »

ItemProductPrototype :: struct or {ItemID, uint16}
https://lua-api.factorio.com/latest/typ ... otype.html
When using the `{ItemID, uint16}` version, what does the second value represent? In this case I think it's `amount`, but that's not specified anywhere in the docs.
SpawnPoint :: struct or {double, double}
https://lua-api.factorio.com/latest/typ ... Point.html
The struct only has two properties, both doubles, but what order do they go in for the second variation?

There are probably other places with these same or similar ambiguities. It would be great if they were clarified.

Bilka
Factorio Staff
Factorio Staff
Posts: 3139
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Specify meaning of alternative numbered key "tuple"s for struct types

Post by Bilka »

It's always in the order of the struct with the default sort. But I still added textual descriptions to all prototype stage tuples in the next version.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

sparr
Smart Inserter
Smart Inserter
Posts: 1327
Joined: Fri Feb 14, 2014 5:52 pm
Contact:

Re: Specify meaning of alternative numbered key "tuple"s for struct types

Post by sparr »

I understand the order answer for the second example, but not for the first. Do you mean that a tuple that takes one string and one number will always be the first string and first number in the sorted fields?

Bilka
Factorio Staff
Factorio Staff
Posts: 3139
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Specify meaning of alternative numbered key "tuple"s for struct types

Post by Bilka »

sparr wrote:
Sat Dec 09, 2023 9:49 pm
I understand the order answer for the second example, but not for the first. Do you mean that a tuple that takes one string and one number will always be the first string and first number in the sorted fields?
The only tuples that take an ItemID and an uint16 are the ItemIngredientPrototype and ItemProductPrototype, and for both of them they set the name (ItemID) and the amount (uint16).

And those are the first fields of those types in the default unsorted struct. But with the improved descriptions that no longer matters because the descriptions just state what the tuple members mean.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

Bilka
Factorio Staff
Factorio Staff
Posts: 3139
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Specify meaning of alternative numbered key "tuple"s for struct types

Post by Bilka »

Please also note that the tuple format for ItemProductPrototype will be removed in 2.0
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

Post Reply

Return to “Resolved Requests”