Page 1 of 1

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

Posted: Wed Nov 15, 2023 3:29 am
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.

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

Posted: Tue Dec 05, 2023 6:41 pm
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.

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

Posted: Sat Dec 09, 2023 9:49 pm
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?

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

Posted: Mon Dec 11, 2023 2:12 pm
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.

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

Posted: Mon Dec 11, 2023 3:55 pm
by Bilka
Please also note that the tuple format for ItemProductPrototype will be removed in 2.0