3 local MAX_VOLUME = 30 * 30 * 30
6 local volume = we.volume
7 local safewrap = function(func)
8 return function(pos1, pos2, ...)
9 if validbox(pos1, pos2) then
10 return func(pos1, pos2, ...)
16 local validbox = function(pos1, pos2)
17 tpos1, tpos2 = we.sort_pos(pos1, pos2)
19 if volume(tpos1, tpos2) > MAX_VOLUME then
23 --check for ownership of area if ownership mod is installed
26 for _, def in pairs(owner_defs) do
28 local tdef = {x1=def.x1, x2 = def.x2, y1=def.y1, y2=def.y2, z1=def.z1, z2=def.z2}
29 if tdef.x1 > tdef.x2 then
30 tdef.x1, tdef.x2 = tdef.x2, tdef.x1
32 if tdef.y1 > tdef.y2 then
33 tdef.y1, tdef.y2 = tdef.y2, tdef.y1
35 if tdef.z1 > tdef.z2 then
36 tdef.z1, tdef.z2 = tdef.z2, tdef.z1
40 if tpos1.x >= tdef.x1 and tpos1.x <= tdef.x2
41 and tpos2.x >= tdef.x1 and tpos2.x <= tdef.x2
42 and tpos1.y >= tdef.y1 and tpos1.y <= tdef.y2
43 and tpos2.y >= tdef.y1 and tpos2.y <= tdef.y2
44 and tpos1.z >= tdef.z1 and tpos1.z <= tdef.z2
45 and tpos2.z >= tdef.z1 and tpos2.z <= tdef.z2
46 and name == def.owner then --wip: name isn't available here
60 sort_pos = we.sort_pos,
62 set = safewrap(we.set),
63 replace = safewrap(we.replace),
64 replaceinverse = safewrap(we.replaceinverse),
65 copy = function(pos1, pos2, axis, amount)
66 tpos1, tpos2 = we.sort_pos(pos1, pos2)
67 tpos1[axis] = tpos1[axis] + amount
68 tpos2[axis] = tpos2[axis] + amount
69 if validbox(pos1, pos2) and validbox(tpos1, tpos2) then
70 we.copy(pos1, pos2, axis, amount)
75 move = function(pos1, pos2, axis, amount)
76 tpos1, tpos2 = we.sort_pos(pos1, pos2)
77 tpos1[axis] = tpos1[axis] + amount
78 tpos2[axis] = tpos2[axis] + amount
79 if validbox(pos1, pos2) and validbox(tpos1, tpos2) then
80 we.move(pos1, pos2, axis, amount)
85 stack = function(pos1, pos2, axis, count)
86 tpos1, tpos2 = we.sort_pos(pos1, pos2)
87 local length = (tpos2[axis] - tpos1[axis] + 1) * count
89 tpos1[axis] = tpos1[axis] + length
91 tpos2[axis] = tpos2[axis] + length
93 if validbox(tpos1, tpos2) then
94 we.stack(pos1, pos2, axis, amount)
99 --wip: add transpose, rotate safely
100 flip = safewrap(we.flip),
101 orient = safewrap(we.orient),
102 fixlight = safewrap(we.fixlight),
103 --wip: add primitives here
105 hide = safewrap(we.hide),
106 suppress = safewrap(we.suppress),
107 highlight = safewrap(we.highlight),
108 restore = safewrap(we.restore),
109 serialize = safewrap(we.serialize),
110 allocate = we.allocate,
111 deserialize = function(originpos, value)
112 local tpos1, tpos2 = we.allocate(originpos, value)
113 if validbox(tpos1, tpos2) then
114 we.deserialize(originpos, value)