Hi,
I was reading about tables here:
http://www.gammon.com.au/forum/?id=6036
t = {
dwarf = { str = “22”, dex = “23”, wis = “18” },
human = { str = “20”, dex = “20”, wis = “20” },
elf = { str = “18”, dex = “24”, wis = “25” },
}
And am wondering if I print something from this table I use:
print(t.dwarf.str)
But what if I want to randomly print either strength dex or wisdom?
I thought I would use math.random on an index but I can’t manage to substitute it for an index in the normal way I do it when I only have one value in the table.
t={“a”,“b”,“c”}
print(t[2])
How would I do this?
print(t.dwarf[1]) or print(t.dwarf.[1]) gives a nil value.
[import]uid: 100901 topic_id: 19692 reply_id: 319692[/import]