mirror of
https://github.com/minetest-mods/areas.git
synced 2024-12-24 17:50:40 +01:00
Centralize position getting and sorting
This commit is contained in:
parent
02905caaeb
commit
abd6a4c709
@ -7,10 +7,8 @@ minetest.register_chatcommand("protect", {
|
|||||||
if param == "" then
|
if param == "" then
|
||||||
return false, "Invalid usage, see /help protect."
|
return false, "Invalid usage, see /help protect."
|
||||||
end
|
end
|
||||||
local pos1, pos2 = areas:getPos1(name), areas:getPos2(name)
|
local pos1, pos2 = areas:getPos(name)
|
||||||
if pos1 and pos2 then
|
if not (pos1 and pos2) then
|
||||||
pos1, pos2 = areas:sortPos(pos1, pos2)
|
|
||||||
else
|
|
||||||
return false, "You need to select an area first."
|
return false, "You need to select an area first."
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -45,10 +43,8 @@ minetest.register_chatcommand("set_owner", {
|
|||||||
return false, "Incorrect usage, see /help set_owner."
|
return false, "Incorrect usage, see /help set_owner."
|
||||||
end
|
end
|
||||||
|
|
||||||
local pos1, pos2 = areas:getPos1(name), areas:getPos2(name)
|
local pos1, pos2 = areas:getPos(name)
|
||||||
if pos1 and pos2 then
|
if not (pos1 and pos2) then
|
||||||
pos1, pos2 = areas:sortPos(pos1, pos2)
|
|
||||||
else
|
|
||||||
return false, "You need to select an area first."
|
return false, "You need to select an area first."
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -87,10 +83,8 @@ minetest.register_chatcommand("add_owner", {
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local pos1, pos2 = areas:getPos1(name), areas:getPos2(name)
|
local pos1, pos2 = areas:getPos(name)
|
||||||
if pos1 and pos2 then
|
if not (pos1 and pos2) then
|
||||||
pos1, pos2 = areas:sortPos(pos1, pos2)
|
|
||||||
else
|
|
||||||
return false, "You need to select an area first."
|
return false, "You need to select an area first."
|
||||||
end
|
end
|
||||||
|
|
||||||
|
12
pos.lua
12
pos.lua
@ -118,12 +118,12 @@ minetest.register_chatcommand("area_pos", {
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
function areas:getPos1(playerName)
|
function areas:getPos(playerName)
|
||||||
return areas.pos1[playerName]
|
local pos1, pos2 = areas.pos1[playerName], areas.pos2[playerName]
|
||||||
end
|
if not (pos1 and pos2) then
|
||||||
|
return nil
|
||||||
function areas:getPos2(playerName)
|
end
|
||||||
return areas.pos2[playerName]
|
return areas:sortPos(pos1, pos2)
|
||||||
end
|
end
|
||||||
|
|
||||||
function areas:setPos1(playerName, pos)
|
function areas:setPos1(playerName, pos)
|
||||||
|
Loading…
Reference in New Issue
Block a user