mirror of
https://github.com/minetest-mods/areas.git
synced 2024-12-27 11:10:40 +01:00
Added optional worldedit dependency and used it for selection.
This commit is contained in:
parent
177f659f4e
commit
d3b91a2aeb
1
depends.txt
Normal file
1
depends.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
worldedit?
|
23
pos.lua
23
pos.lua
@ -118,8 +118,21 @@ 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
|
||||||
|
local pos1, pos2 = worldedit.pos1[playerName], worldedit.pos2[playerName];
|
||||||
|
else
|
||||||
|
local pos1, pos2 = areas.pos1[playerName], areas.pos2[playerName];
|
||||||
|
end
|
||||||
|
|
||||||
if not (pos1 and pos2) then
|
if not (pos1 and pos2) then
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
@ -130,14 +143,22 @@ function areas:getPos(playerName)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function areas:setPos1(playerName, pos)
|
function areas:setPos1(playerName, pos)
|
||||||
|
if areas.useWorldedit(playerName) then
|
||||||
|
worldedit.pos1[playerName] = pos;
|
||||||
|
else
|
||||||
areas.pos1[playerName] = pos
|
areas.pos1[playerName] = pos
|
||||||
areas.markPos1(playerName)
|
areas.markPos1(playerName)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function areas:setPos2(playerName, pos)
|
function areas:setPos2(playerName, pos)
|
||||||
|
if areas.useWorldedit(playerName) then
|
||||||
|
worldedit.pos2[playerName] = pos;
|
||||||
|
else
|
||||||
areas.pos2[playerName] = pos
|
areas.pos2[playerName] = pos
|
||||||
areas.markPos2(playerName)
|
areas.markPos2(playerName)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
minetest.register_on_punchnode(function(pos, node, puncher)
|
minetest.register_on_punchnode(function(pos, node, puncher)
|
||||||
|
Loading…
Reference in New Issue
Block a user