Draw arrow for player holding map
This commit is contained in:
parent
42ea5635f4
commit
94523cbef6
30
init.lua
30
init.lua
|
@ -373,7 +373,6 @@ minetest.register_on_joinplayer(
|
||||||
scale = { x = 4, y = 4 }
|
scale = { x = 4, y = 4 }
|
||||||
}
|
}
|
||||||
local dot_def = table.copy(map_def)
|
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.maps[player_name] = player:hud_add(map_def)
|
||||||
maps.dots[player_name] = player:hud_add(dot_def)
|
maps.dots[player_name] = player:hud_add(dot_def)
|
||||||
maps.minp[player_name] = { x=-32000, y=0, z=0 }
|
maps.minp[player_name] = { x=-32000, y=0, z=0 }
|
||||||
|
@ -428,6 +427,35 @@ minetest.register_globalstep(
|
||||||
maps.posx[player_name] = pos.x
|
maps.posx[player_name] = pos.x
|
||||||
maps.posz[player_name] = pos.z
|
maps.posz[player_name] = pos.z
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue