mirror of
https://repo.or.cz/minetest_hudbars.git
synced 2024-11-28 01:53:46 +01:00
Fix breath, lower update rate
This commit is contained in:
parent
9fb42bd469
commit
2da67c5fa1
15
init.lua
15
init.lua
@ -26,6 +26,7 @@ HUD_AIR_OFFSET = {x=15,y=-15}
|
|||||||
HUD_ARMOR_POS = {x=0.5,y=0.9}
|
HUD_ARMOR_POS = {x=0.5,y=0.9}
|
||||||
HUD_ARMOR_OFFSET = {x=-175, y=-15}
|
HUD_ARMOR_OFFSET = {x=-175, y=-15}
|
||||||
|
|
||||||
|
HUD_TICK = 0.1
|
||||||
HUD_HUNGER_TICK = 300
|
HUD_HUNGER_TICK = 300
|
||||||
|
|
||||||
HUD_ENABLE_HUNGER = minetest.setting_getbool("hud_hunger_enable")
|
HUD_ENABLE_HUNGER = minetest.setting_getbool("hud_hunger_enable")
|
||||||
@ -241,18 +242,25 @@ minetest.register_on_joinplayer(function(player)
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
minetest.register_on_respawnplayer(function(player)
|
minetest.register_on_respawnplayer(function(player)
|
||||||
|
-- reset player breath since the engine doesnt
|
||||||
|
player:set_breath(11)
|
||||||
|
-- reset hunger (and save)
|
||||||
hud.hunger[player:get_player_name()] = 20
|
hud.hunger[player:get_player_name()] = 20
|
||||||
minetest.after(0.5, function()
|
if HUD_ENABLE_HUNGER then
|
||||||
if HUD_ENABLE_HUNGER then hud.set_hunger(player) end
|
minetest.after(0.5, hud.set_hunger, player)
|
||||||
end)
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
local main_timer = 0
|
||||||
local timer = 0
|
local timer = 0
|
||||||
local timer2 = 0
|
local timer2 = 0
|
||||||
minetest.after(2.5, function()
|
minetest.after(2.5, function()
|
||||||
minetest.register_globalstep(function(dtime)
|
minetest.register_globalstep(function(dtime)
|
||||||
|
main_timer = main_timer + dtime
|
||||||
timer = timer + dtime
|
timer = timer + dtime
|
||||||
timer2 = timer2 + dtime
|
timer2 = timer2 + dtime
|
||||||
|
if main_timer > HUD_TICK then
|
||||||
|
main_timer = 0
|
||||||
for _,player in ipairs(minetest.get_connected_players()) do
|
for _,player in ipairs(minetest.get_connected_players()) do
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
|
|
||||||
@ -285,6 +293,7 @@ minetest.after(2.5, function()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
end
|
||||||
if timer > 4 then timer = 0 end
|
if timer > 4 then timer = 0 end
|
||||||
if timer2 > HUD_HUNGER_TICK then timer2 = 0 end
|
if timer2 > HUD_HUNGER_TICK then timer2 = 0 end
|
||||||
end)
|
end)
|
||||||
|
Loading…
Reference in New Issue
Block a user