So, for a 2D tile-based game I've been creating I want to use dictionaries to index individual tiles. But the problem is, I can't use tables or Vector2's as keys, as I'd like to.
I'm trying to do something like this:
map = {
[{0,0}] = "tile" -- 'tile' object at 0,0
}
But whenever I try to print the value using this:
local x = 0
local y = 0
print(map[{x,y}]) -- prints tile at the 0,0 coordinate
It always returns nil.
I have found a hacky workaround, however. I could just turn the X and Y components of the table into a string, like so:
map = {
["00"] = "tile"
}
local x = 0
local y = 0
print(map[tostring(x)..tostring(y)])
It works but it's a rather inelegant solution that I might as well scrap for something more organized.
Any help would be appreciated.
