Team Spartan Cookies & Milk Forums
Funny Lua5.1 bug - Printable Version

+- Team Spartan Cookies & Milk Forums (https://teamscm.co.uk)
+-- Forum: Garry's Mod (https://teamscm.co.uk/forum-4.html)
+--- Forum: Starfall (https://teamscm.co.uk/forum-7.html)
+--- Thread: Funny Lua5.1 bug (/thread-2034.html)



Funny Lua5.1 bug - ILoveYou - 19-11-2016

Everyone knows that we cant use numbers inside variable names, but:

Code:
Table[Player:steamID()] = true

gives a output like:

Code:
Table = { STEAM_0:1:0000000 = true }

and now, how's that possible? xD

i tried to compress tables with lzw(1)table2string- 2)lzw- 3)string2table), but with this thing i'm unable to do the last point.


RE: Funny Lua5.1 bug - Red The Blue Color - 20-11-2016

You can use numbers in variable names in lua you just can't have it start with a number...

and the steamid is a string anyways


RE: Funny Lua5.1 bug - Person8880 - 20-11-2016

I'd firstly question why you're trying to "compress tables" in the first place. Turning a table into a string and then compressing that is not a good way to encode a table.

Secondly, no this is not a Lua 5.1 bug. There's a distinct difference between a variable (which is a syntax construct) and a key in a table (which is purely data). You can have any string value as a table key, whether it would be valid to write as a variable or not. For example, these are all valid:
{
[ "function" ] = true,
[ "12345" ] = true,
[ "+" ] = true
}