Implement speedometer

This commit is contained in:
Wuzzy 2016-07-28 02:58:20 +02:00
parent 8c28944aff
commit 62bca4fdee

@ -1,5 +1,8 @@
local orienteering = {} local orienteering = {}
orienteering.playerhuds = {} orienteering.playerhuds = {}
orienteering.settings = {}
orienteering.settings.speed_unit = "m/s"
orienteering.settings.length_unit = "m"
-- Displays height (Y) -- Displays height (Y)
minetest.register_tool("orienteering:altimeter", { minetest.register_tool("orienteering:altimeter", {
@ -172,8 +175,9 @@ function update_hud_displays(player)
str_time = "" str_time = ""
end end
if speedometer or gps then local speed = vector.length(player:get_player_velocity())
str_speed = "" if speedometer then
str_speed = string.format("Velocity: %.2f %s", speed, orienteering.settings.speed_unit)
else else
str_speed = "" str_speed = ""
end end