mirror of
https://github.com/minetest-mods/i3.git
synced 2024-12-26 19:00:39 +01:00
Prevent adding waypoint at same pos
This commit is contained in:
parent
2274b426a5
commit
d612f8697d
11
init.lua
11
init.lua
@ -74,7 +74,7 @@ local min, max, floor, ceil, random =
|
||||
local pairs, ipairs, next, type, setmetatable, tonum, unpack, select =
|
||||
pairs, ipairs, next, type, setmetatable, tonumber, unpack, select
|
||||
|
||||
local vec_add, vec_mul = vector.add, vector.multiply
|
||||
local vec_add, vec_mul, vec_eq, vec_round = vector.add, vector.multiply, vector.equals, vector.round
|
||||
|
||||
local MAX_FAVS = 6
|
||||
local ITEM_BTN_SIZE = 1.1
|
||||
@ -2676,6 +2676,14 @@ i3.new_tab {
|
||||
return
|
||||
|
||||
elseif fields.waypoint_add then
|
||||
local pos = player:get_pos()
|
||||
|
||||
for _, v in ipairs(data.waypoints) do
|
||||
if vec_eq(vec_round(pos), vec_round(v.pos)) then
|
||||
return msg(name, "You already set a waypoint at this position")
|
||||
end
|
||||
end
|
||||
|
||||
local waypoint = fields.waypoint_name
|
||||
|
||||
if fields.waypoint_name == "" then
|
||||
@ -2683,7 +2691,6 @@ i3.new_tab {
|
||||
end
|
||||
|
||||
local color = random(0xffffff)
|
||||
local pos = player:get_pos()
|
||||
|
||||
local id = player:hud_add {
|
||||
hud_elem_type = "waypoint",
|
||||
|
Loading…
Reference in New Issue
Block a user