make inventory item change color according to waypoint color

This commit is contained in:
whosit 2021-06-06 21:58:33 +03:00
parent cefafaef3b
commit ffbb4c4015
3 changed files with 6 additions and 1 deletions

View File

@ -333,7 +333,10 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
if color then
color = math.max(math.min(color, 0xFFFFFF), 0x0) -- for some reason seems to work fine without this
set_compass_meta_color(meta, color)
end
-- print(dump(meta:to_table()))
-- thanks to Boot@YL for suggesting this
meta:set_string("color", ("#%06X"):format(color))
end
local coords = coords_from_string(fields.coords)
if coords then
@ -366,6 +369,8 @@ minetest.register_tool(
description = DEFAULT_DESCRIPTION,
--short_description = "Waypoint compass",
inventory_image = "waypoint_compass_inventory_image.png",
inventory_overlay = "waypoint_compass_inventory_image_overlay.png",
color = "#f6d0a5",
wield_scale = {x = 0.5, y = 0.5, z = 0.5},
range = 2.0, -- TODO what's the good range?
on_place = function(itemstack, placer, pointed_thing)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB