Page 1 of 1

[1.1.74] GUI Tags stringified keys in nested table

Posted: Wed Dec 28, 2022 6:45 pm
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

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

Posted: Thu Dec 29, 2022 10:25 pm
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.

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

Posted: Mon Mar 06, 2023 8:08 pm
by Rseding91
Thanks for the report however for now; this is simply how tags behave.