✓ Accepted answer
local aTable = {}
local aString = "JustAString"
aTable[aString] = true
The key is "JustAstring" and the value is true.
After you set the value, these two are exactly the same way to point to the position in the table:
local aTable = {}
local aString = "JustAString"
aTable[aString] = true
print(aTable[aString])
print(aTable.JustAString)
It's important to know you can only do this with string keys, so use an objects.Name if you wish to store object references in the table.
And to show that it is indeed adding different records:
local aTable = {}
local aString = "JustAString"
aTable[aString] = true
aString = "ADifferentString"
aTable[aString] = 25
print(aTable.JustAString)
print(aTable[aString])
2 comments
Thanks, this really helps.
Any time, glad to help.