From 94523cbef67e3366111ee4e895a4dcdcbbe47a69 Mon Sep 17 00:00:00 2001 From: Nils Dagsson Moskopp Date: Thu, 19 May 2022 17:56:33 +0200 Subject: [PATCH] Draw arrow for player holding map --- init.lua | 30 +++++++++++++++++++++++++++++- textures/maps_arrow.tga | Bin 0 -> 179 bytes textures/maps_arrow_diagonal.tga | Bin 0 -> 180 bytes 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 textures/maps_arrow.tga create mode 100644 textures/maps_arrow_diagonal.tga diff --git a/init.lua b/init.lua index 89333f4..e17c46d 100644 --- a/init.lua +++ b/init.lua @@ -373,7 +373,6 @@ minetest.register_on_joinplayer( scale = { x = 4, y = 4 } } local dot_def = table.copy(map_def) - dot_def.text = "maps_x.tga" -- "player.png^[resize:4x8" maps.maps[player_name] = player:hud_add(map_def) maps.dots[player_name] = player:hud_add(dot_def) maps.minp[player_name] = { x=-32000, y=0, z=0 } @@ -428,6 +427,35 @@ minetest.register_globalstep( maps.posx[player_name] = pos.x maps.posz[player_name] = pos.z end + local marker + local yaw = ( + math.floor( + player:get_look_horizontal() + * 180 / math.pi / 45 + 0.5 + ) % 8 + ) * 45 + if ( + yaw == 0 or + yaw == 90 or + yaw == 180 or + yaw == 270 + ) then + marker = "maps_arrow.tga" .. "^[transformR" .. yaw + elseif ( + yaw == 45 or + yaw == 135 or + yaw == 225 or + yaw == 315 + ) then + marker = "maps_arrow_diagonal.tga" .. "^[transformR" .. (yaw - 45) + end + if marker then + player:hud_change( + maps.dots[player_name], + "text", + marker + ) + end end end ) diff --git a/textures/maps_arrow.tga b/textures/maps_arrow.tga new file mode 100644 index 0000000000000000000000000000000000000000..91fccf460cc43a800d24ef5de25fd8c565592a86 GIT binary patch literal 179 zcmZQz;9`IQb_R9^1r9K;1xWq}vlyYW|C{~;0f+|{Zv-*GLSPn1(f<~Z3NQ78!&x9+NKmM2m}ju3zn^Y|o2QSf9s>Y}WiO-v literal 0 HcmV?d00001 diff --git a/textures/maps_arrow_diagonal.tga b/textures/maps_arrow_diagonal.tga new file mode 100644 index 0000000000000000000000000000000000000000..6798c9f21442b18323a1359eb3c9591a5cc04e44 GIT binary patch literal 180 zcmZQz;9`IQb_R9^1&$^Vml22sf%tzThzBD6vw&DY@E-&~G>F55EYJj%fk^#t25~_K sfmDJFWB89y0X7#bhN6t26{HL#4hJDYp{`+`!Jhtpx)E-kKCXHU0F1sb#Q*>R literal 0 HcmV?d00001