forked from nalc/areas
Make legacy table copy entries
This commit is contained in:
parent
57c18fce95
commit
913e1fe6b3
31
legacy.lua
31
legacy.lua
@ -111,31 +111,22 @@ HasOwner = areas.hasOwner
|
||||
|
||||
-- This is entirely untested and may break in strange and new ways.
|
||||
if areas.legacy_table then
|
||||
owner_defs = {}
|
||||
setmetatable(owner_defs, {
|
||||
owner_defs = setmetatable({}, {
|
||||
__index = function(table, key)
|
||||
local a = rawget(areas.areas, key)
|
||||
if a then
|
||||
a.x1 = a.pos1.x
|
||||
a.y1 = a.pos1.y
|
||||
a.z1 = a.pos1.z
|
||||
a.x2 = a.pos2.x
|
||||
a.y2 = a.pos2.y
|
||||
a.z2 = a.pos2.z
|
||||
a.pos1, a.pos2 = nil, nil
|
||||
a.id = key
|
||||
end
|
||||
return a
|
||||
if not a then return a end
|
||||
local b = {}
|
||||
for k, v in pairs(a) do b[k] = v end
|
||||
b.x1, b.y1, b.z1 = b.pos1.x, b.pos1.y, b.pos1.z
|
||||
b.x2, b.y1, b.z2 = b.pos2.x, b.pos2.y, b.pos2.z
|
||||
b.pos1, b.pos2 = nil, nil
|
||||
b.id = key
|
||||
return b
|
||||
end,
|
||||
__newindex = function(table, key, value)
|
||||
local a = value
|
||||
a.pos1, a.pos2 = {}, {}
|
||||
a.pos1.x = a.x1
|
||||
a.pos1.y = a.y1
|
||||
a.pos1.z = a.z1
|
||||
a.pos2.x = a.x2
|
||||
a.pos2.y = a.y2
|
||||
a.pos2.z = a.z2
|
||||
a.pos1, a.pos2 = {x=a.x1, y=a.y1, z=a.z1},
|
||||
{x=a.x2, y=a.y2, z=a.z2}
|
||||
a.x1, a.y1, a.z1, a.x2, a.y2, a.z2 =
|
||||
nil, nil, nil, nil, nil, nil
|
||||
a.name = a.name or "unnamed"
|
||||
|
Loading…
Reference in New Issue
Block a user