Added optional worldedit dependency and used it for selection.

This commit is contained in:
Joseph Pickard 2016-01-09 11:30:03 -05:00
parent 177f659f4e
commit d3b91a2aeb
2 changed files with 34 additions and 12 deletions

1
depends.txt Normal file
View File

@ -0,0 +1 @@
worldedit?

45
pos.lua
View File

@ -118,25 +118,46 @@ minetest.register_chatcommand("area_pos", {
end, end,
}) })
function areas.useWorldedit(playerName)
if minetest.get_modpath("worldedit") then
return nil == playerName or minetest.check_player_privs(playerName, "worldedit");
else
return false;
end
end
function areas:getPos(playerName) function areas:getPos(playerName)
local pos1, pos2 = areas.pos1[playerName], areas.pos2[playerName] if areas.useWorldedit(playerName) then
if not (pos1 and pos2) then local pos1, pos2 = worldedit.pos1[playerName], worldedit.pos2[playerName];
return nil else
end local pos1, pos2 = areas.pos1[playerName], areas.pos2[playerName];
-- Copy positions so that the area table doesn't contain multiple end
-- references to the same position.
pos1, pos2 = vector.new(pos1), vector.new(pos2) if not (pos1 and pos2) then
return areas:sortPos(pos1, pos2) return nil
end
-- Copy positions so that the area table doesn't contain multiple
-- references to the same position.
pos1, pos2 = vector.new(pos1), vector.new(pos2)
return areas:sortPos(pos1, pos2)
end end
function areas:setPos1(playerName, pos) function areas:setPos1(playerName, pos)
areas.pos1[playerName] = pos if areas.useWorldedit(playerName) then
areas.markPos1(playerName) worldedit.pos1[playerName] = pos;
else
areas.pos1[playerName] = pos
areas.markPos1(playerName)
end
end end
function areas:setPos2(playerName, pos) function areas:setPos2(playerName, pos)
areas.pos2[playerName] = pos if areas.useWorldedit(playerName) then
areas.markPos2(playerName) worldedit.pos2[playerName] = pos;
else
areas.pos2[playerName] = pos
areas.markPos2(playerName)
end
end end