Using a coordinate pair as a key in a Lua table
问题 As the title says, I'm trying to use a coordinate pair (x, y) as a key for a table. Here is what I have done so far local test = {_props = {}} local mt = {} local xMax = 5 local yMax = 5 local function coord2index(x, y) return ((x-1) * xMax) + y end mt.__index = function(s, k) if s._props[coord2index(k[1], k[2])] ~= nil then return s._props[coord2index(k[1], k[2])] end end mt.__newindex = function(s, k, v) s._props[coord2index(k[1], k[2])] = v end mt.__call = function (t, k) if type(k) ==