Skip to content
This repository was archived by the owner on Aug 20, 2020. It is now read-only.

Commit 971c17a

Browse files
committed
[Hunger] global_step to timer #179
1 parent 41552c9 commit 971c17a

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

mods/hbhunger/init.lua

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,11 @@ minetest.register_on_respawnplayer(function(player)
9494
hbhunger.exhaustion[name] = 0
9595
end)
9696

97-
local main_timer = 0
9897
local timer = 0
9998
local timer2 = 0
100-
minetest.register_globalstep(function(dtime)
101-
main_timer = main_timer + dtime
102-
timer = timer + dtime
103-
timer2 = timer2 + dtime
104-
if main_timer > HUNGER_HUD_TICK or timer > 10 or timer2 > HUNGER_HUNGER_TICK then
105-
if main_timer > HUNGER_HUD_TICK then main_timer = 0 end
99+
local function hunger_step()
100+
timer = timer + HUNGER_HUD_TICK
101+
timer2 = timer2 + HUNGER_HUD_TICK
106102
for _,player in ipairs(minetest.get_connected_players()) do
107103
local name = player:get_player_name()
108104

@@ -144,9 +140,11 @@ minetest.register_globalstep(function(dtime)
144140
hbhunger.handle_node_actions(nil, nil, player)
145141
end
146142
end
147-
end
143+
--end
148144
if timer > 10 then timer = 0 end
149145
if timer2 > HUNGER_HUNGER_TICK then timer2 = 0 end
150-
end)
146+
minetest.after(HUNGER_HUD_TICK, hunger_step)
147+
end
148+
minetest.after(0, hunger_step)
151149

152150
end

0 commit comments

Comments
 (0)