[1.1.74] GUI Tags stringified keys in nested table

We are aware of them, but they have low priority. We have more important things to do. They go here in order not to take space in the main bug thread list.
User avatar
_CodeGreen
Long Handed Inserter
Long Handed Inserter
Posts: 72
Joined: Sat Mar 05, 2022 11:30 am
Contact:

[1.1.74] GUI Tags stringified keys in nested table

Post by _CodeGreen »

Consider the following GUI element tags:
a = {"one"}
b = {"one", "two"},
c = {nil, "two"},
d = {nil, "two", "three"}

a and b are both sequences, but c and d are not.
the game will leave the sequences alone, but it will stringify the keys of the non-sequences.

Here's a command that adds a button to the player's screen with these tags, and prints out the tags the element has.

Code: Select all

/c local button = game.player.gui.screen.add{type = "button", tags = {a = {"one"}, b = {"one", "two"}, c = {nil, "two"}, d = {nil, "two", "three"}}} game.print(serpent.line(button.tags))
This is the output for the above command:
{a = {"one"}, b = {"one", "two"}, c = {["2"] = "two"}, d = {["2"] = "two", ["3"] = "three"}}
Notice how the keys for c and d are strings instead of numbers.

I'm not sure if this is intended behavior, but it's not documented on latest and left me really confused for about an hour. :P
My Mods | If you can't make it perfect, make it adjustable
Honktown
Smart Inserter
Smart Inserter
Posts: 1045
Joined: Thu Oct 03, 2019 7:10 am
Contact:

Re: [1.1.74] GUI Tags stringified keys in nested table

Post by Honktown »

As side information, when discussed on the Discord, it based on PropertyTrees being [compatible with/existing as] json. json has the two types of containers: arrays and objects. Arrays only have numbered indices (from 1-N, a Lua sequence) and objects only have strings keys. Anything not a sequence can only be stored in JSON in an object, which causes the surprise when numeric keys are stringified.
I have mods! I guess!
Link
Rseding91
Factorio Staff
Factorio Staff
Posts: 14674
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [1.1.74] GUI Tags stringified keys in nested table

Post by Rseding91 »

Thanks for the report however for now; this is simply how tags behave.
If you want to get ahold of me I'm almost always on Discord.
Post Reply

Return to “Minor issues”