This commit is contained in:
whosit 2021-05-28 10:03:23 +03:00
parent 5da1285a18
commit ac0f1a299b

View File

@ -1,3 +1,4 @@
local DEFAULT_DESCRIPTION = "Waypoint compass\n(sneak+place to set point)"
local UPDATE_INTERVAL = 1.31415
local COMPASS_PRECISION = 10 -- set to 1 to show whole number or 10 for 1 decimal
local DEFAULT_WAYPOINT_COLOR = 0xFFFFFF
@ -116,7 +117,7 @@ local function show_hud_waypoint(player, compass_item_meta)
-- store HUD elemnt id to remove it later
if player_waypoints[player_name] then
minetest.log("error","[MOD] waypoint_compass: " ..
player:get_player_name() ..
player_name ..
" got their HUD stuck on screen?")
end
player_waypoints[player_name] = waypoint
@ -157,6 +158,7 @@ end
local timer = 0
minetest.register_globalstep(function(dtime)
-- check if wielded item is a compass and update waypoints
timer = timer + dtime
if timer > UPDATE_INTERVAL then
for _,player in pairs(minetest.get_connected_players()) do
@ -242,8 +244,8 @@ local function show_basic_dialog(itemstack, player)
-- set focus to "close" button to preven accidental edting
local formspec_head = "formspec_version[4]size[14,3]set_focus[close;]"
local coords = coords_to_string(get_compass_meta_pos(meta))
local field_coords = ("field[0.5,0.6;4,0.8;coords;Coords;%s]"):format(minetest.formspec_escape(coords))
local label = get_compass_meta_label(meta)
local field_coords = ("field[0.5,0.6;4,0.8;coords;Coordinates;%s]"):format(minetest.formspec_escape(coords))
local label = get_compass_meta_label(meta) or "destination"
local field_destination = ("field[4.5,0.6;7,0.8;label;Label;%s]"):format(minetest.formspec_escape(label))
local color = ("%06X"):format(get_compass_meta_color(meta))
local field_color = ("field[11.5,0.6;2.0,0.8;color;Color;%s]"):format(minetest.formspec_escape(color))
@ -337,7 +339,7 @@ end)
minetest.register_tool(
"waypoint_compass:compass", {
description = "Waypoint compass\n(sneak+place to set point)",
description = DEFAULT_DESCRIPTION,
--short_description = "Waypoint compass",
inventory_image = "waypoint_compass_inventory_image.png",
wield_scale = {x = 0.5, y = 0.5, z = 0.5},