Let's say I have this table:
local Rarities = { ["Common"] = {"Oof1", "Oof2"}, ["Common2"] = {"Oofa", "Oofb"}, } for i, v in pairs(Rarities) do print(v) end
of course, this would print something like Table:9B9B9B9B
What I would like simply is to output "Common".
If you simply want the indexes, then you should be printing i
, not v
If you needed to print in the values inside of i
, then you would simply unpack it.
The reason why it is printing table's memory location is because
I) You are printing the value of index, not the index itself
II) Simply because you are printing the table, which if you wanted to get it's value, you would have to unpack
it. You have a matrix. That is why.
local Rarities = { ["Common"] = {"Oof1", "Oof2"}, ["Common2"] = {"Oofa", "Oofb"}, } for i, v in pairs(Rarities) do print(i) print(unpack(v)); end
would print
--[[ Common2 Oofa Oofb Common Oof1 Oof2 ]]
Edit: Whoops forgot Lua 5.1 uses unpack
not table.unpack
.