mirror of
https://github.com/minetest-mods/areas.git
synced 2024-12-26 02:30:40 +01:00
Added optional support for using worledit for selections.
This commit is contained in:
parent
8b0b8c1ad2
commit
79821b0892
1
depends.txt
Normal file
1
depends.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
worldedit?
|
51
pos.lua
51
pos.lua
@ -118,25 +118,52 @@ minetest.register_chatcommand("area_pos", {
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
function areas.useWorldedit(playerName)
|
||||||
|
if worldedit then
|
||||||
|
if nil == playerName then
|
||||||
|
return true;
|
||||||
|
elseif minetest.check_player_privs(playerName, {worldedit = true}) then
|
||||||
|
return true;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return false;
|
||||||
|
end
|
||||||
|
|
||||||
function areas:getPos(playerName)
|
function areas:getPos(playerName)
|
||||||
local pos1, pos2 = areas.pos1[playerName], areas.pos2[playerName]
|
local pos1, pos2 = nil, nil;
|
||||||
if not (pos1 and pos2) then
|
if areas.useWorldedit(playerName) then
|
||||||
return nil
|
pos1, pos2 = worldedit.pos1[playerName], worldedit.pos2[playerName];
|
||||||
end
|
else
|
||||||
-- Copy positions so that the area table doesn't contain multiple
|
pos1, pos2 = areas.pos1[playerName], areas.pos2[playerName];
|
||||||
-- references to the same position.
|
end
|
||||||
pos1, pos2 = vector.new(pos1), vector.new(pos2)
|
|
||||||
return areas:sortPos(pos1, pos2)
|
if not (pos1 and pos2) then
|
||||||
|
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;
|
||||||
|
worldedit.mark_pos1(playerName);
|
||||||
|
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;
|
||||||
|
worldedit.mark_pos2(playerName);
|
||||||
|
else
|
||||||
|
areas.pos2[playerName] = pos
|
||||||
|
areas.markPos2(playerName)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user