mirror of
https://github.com/minetest-mods/areas.git
synced 2024-12-24 17:50:40 +01:00
Reduce code duplication in register_on_punchnode
Merges "pos1" and "pos1only" into the same code.
This commit is contained in:
parent
c9f1cf2fac
commit
733e263f86
20
pos.lua
20
pos.lua
@ -229,24 +229,18 @@ minetest.register_on_punchnode(function(pos, node, puncher)
|
|||||||
local name = puncher:get_player_name()
|
local name = puncher:get_player_name()
|
||||||
-- Currently setting position
|
-- Currently setting position
|
||||||
if name ~= "" and areas.set_pos[name] then
|
if name ~= "" and areas.set_pos[name] then
|
||||||
if areas.set_pos[name] == "pos1" then
|
if areas.set_pos[name] == "pos2" then
|
||||||
areas:setPos1(name, pos)
|
|
||||||
areas.set_pos[name] = "pos2"
|
|
||||||
minetest.chat_send_player(name,
|
|
||||||
S("Position @1 set to @2", "1",
|
|
||||||
minetest.pos_to_string(pos)))
|
|
||||||
elseif areas.set_pos[name] == "pos1only" then
|
|
||||||
areas:setPos1(name, pos)
|
|
||||||
areas.set_pos[name] = nil
|
|
||||||
minetest.chat_send_player(name,
|
|
||||||
S("Position @1 set to @2", "1",
|
|
||||||
minetest.pos_to_string(pos)))
|
|
||||||
elseif areas.set_pos[name] == "pos2" then
|
|
||||||
areas:setPos2(name, pos)
|
areas:setPos2(name, pos)
|
||||||
areas.set_pos[name] = nil
|
areas.set_pos[name] = nil
|
||||||
minetest.chat_send_player(name,
|
minetest.chat_send_player(name,
|
||||||
S("Position @1 set to @2", "2",
|
S("Position @1 set to @2", "2",
|
||||||
minetest.pos_to_string(pos)))
|
minetest.pos_to_string(pos)))
|
||||||
|
else
|
||||||
|
areas:setPos1(name, pos)
|
||||||
|
areas.set_pos[name] = areas.set_pos[name] == "pos1" and "pos2" or nil
|
||||||
|
minetest.chat_send_player(name,
|
||||||
|
S("Position @1 set to @2", "1",
|
||||||
|
minetest.pos_to_string(pos)))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
Loading…
Reference in New Issue
Block a user