This post has been marked by the post author as the answer.
Lua only has three data 'types': tables, strings and numbers.
A table can contain other tables (or lists if you prefer), strings, numbers and functions.
A table consists of a key/value pairing, the key can be anything you want and so can the value.
If you do not provide a key then Lua generates them starting at 1 and going up sequentially.
So:
local myTable = { 'a', 'b', 'c', 'd' }
Creates a table with key/value pairings of 1:'a', 2:'b', 3:'c' and 4:'d'.
So myTable[ 3 ] will return 'c'.
local myTable = { a = 1, b = 2, c = 3, d = 4 }
Creates a table with key/value pairings of 'a':1, 'b':2, 'c':3 and 'd':4.
So myTable[ 'c' ] would return 3.
The best way of accessing a table is via the pairs and ipairs functions like this:
for k, v in pairs( myTable ) do
<some code>
end
This iterates over all entries of table myTable returning the key in k and the value in v.
For example:
for k, v in pairs( g_Entity ) do
if v.health > 0 then SetEntityHealth( k, 0 ) end
end
Would 'kill' all entities. (not that you would want to do that but you get the idea)
btw table[ 'a' ] can also be written as table.a, I prefer the latter as it is more readable imo.
Been there, done that, got all the T-Shirts!