Skip to content

Commit

Permalink
Changed location_set.of_pairs() to work with different formats of x,y…
Browse files Browse the repository at this point in the history
… coordinate tables.
  • Loading branch information
jleldridge committed May 16, 2013
1 parent a7272c7 commit 0d8bd9f
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion data/lua/location_set.lua
Expand Up @@ -106,8 +106,32 @@ end

function methods:of_pairs(t)
local values = self.values

for i,v in ipairs(t) do
values[index(v[1], v[2])] = true
local value_table = {}
if (v.x) and (v.y) then
for k,val in pairs(v) do
if (k ~= "x") and (k ~= "y") then
value_table[k] = val
end
end
if (next(value_table) ~= nil) then
values[index(v.x, v.y)] = value_table
else
values[index(v.x, v.y)] = true
end
else
for k,val in pairs(v) do
if (k ~= 1) and (k ~= 2) then
value_table[k] = val
end
end
if (next(value_table) ~= nil) then
values[index(v[1], v[2])] = value_table
else
values[index(v[1], v[2])] = true
end
end
end
end

Expand Down

0 comments on commit 0d8bd9f

Please sign in to comment.