mirror of
https://repo.or.cz/minetest_orienteering.git
synced 2024-12-04 21:03:49 +01:00
Fix crash when attachment velocity returned nil
This commit is contained in:
parent
6b4549641f
commit
0fdecb5afe
27
init.lua
27
init.lua
@ -333,19 +333,22 @@ function orienteering.update_hud_displays(player)
|
||||
str_time = ""
|
||||
end
|
||||
|
||||
local speed_hor, speed_ver
|
||||
local v
|
||||
local attach = player:get_attach()
|
||||
if attach == nil then
|
||||
v = player:get_player_velocity()
|
||||
else
|
||||
v = attach:getvelocity()
|
||||
end
|
||||
speed_ver = v.y
|
||||
v.y = 0
|
||||
speed_hor = vector.length(v)
|
||||
|
||||
if speedometer or quadcorder then
|
||||
local speed_hor, speed_ver
|
||||
local v
|
||||
local attach = player:get_attach()
|
||||
if attach == nil then
|
||||
v = player:get_player_velocity()
|
||||
else
|
||||
v = attach:getvelocity()
|
||||
if not v then
|
||||
v = player:get_player_velocity()
|
||||
end
|
||||
end
|
||||
speed_ver = v.y
|
||||
v.y = 0
|
||||
speed_hor = vector.length(v)
|
||||
|
||||
local u = orienteering.settings.speed_unit
|
||||
str_speed = S("Speed: hor.: @1 @2, vert.: @3 @4", string.format("%.1f", speed_hor), u, string.format("%.1f", speed_ver), u)
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user