if label is empty, show coords instead

This commit is contained in:
whosit 2021-05-28 10:41:58 +03:00
parent 75223aa448
commit b49427f283

View File

@ -23,7 +23,7 @@ end
local function set_compass_meta_label(meta, label)
meta:set_string("waypoint_compass:label", label)
if label == "coords" then
if label == "" then
local pos = get_compass_meta_pos(meta)
if pos then
meta:set_string("description", string.format("Waypoint compass to %s", minetest.pos_to_string(pos)))
@ -44,7 +44,7 @@ end
local function set_compass_meta_pos(meta, pos)
local pos_str = minetest.pos_to_string(pos)
meta:set_string("waypoint_compass:position", pos_str)
if get_compass_meta_label(meta) == "coords" then
if get_compass_meta_label(meta) == "" then
meta:set_string("description", string.format("Waypoint compass to %s", minetest.pos_to_string(pos)))
end
end
@ -112,7 +112,7 @@ local function show_hud_waypoint(player, compass_item_meta)
local waypoint_pos = get_compass_meta_pos(compass_item_meta)
local waypoint_name = get_compass_meta_label(compass_item_meta)
-- show coords instead of name
if waypoint_name == "coords" and waypoint_pos then
if waypoint_name == "" and waypoint_pos then
waypoint_name = minetest.pos_to_string(waypoint_pos)
end
local waypoint_color = get_compass_meta_color(compass_item_meta)