1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2025-03-31 09:40:43 +02:00

[mana] Convert globalstep for #179

This commit is contained in:
LeMagnesium 2016-05-27 22:36:21 +02:00
parent 8cbcf3ae74
commit 0c8d2ac729

View File

@ -240,34 +240,31 @@ end)
mana.regen_timer = 0 mana.regen_timer = 0
minetest.register_globalstep(function(dtime) function mana_regen_step()
mana.regen_timer = mana.regen_timer + dtime local players = minetest.get_connected_players()
if mana.regen_timer >= mana.settings.regen_timer then for i=1, #players do
local factor = math.floor(mana.regen_timer / mana.settings.regen_timer) local name = players[i]:get_player_name()
local players = minetest.get_connected_players() if mana.playerlist[name] ~= nil then
for i=1, #players do if players[i]:get_hp() > 0 then
local name = players[i]:get_player_name() local plus = mana.playerlist[name].regen
if mana.playerlist[name] ~= nil then -- Compability check for version <= 1.0.2 which did not have the remainder field
if players[i]:get_hp() > 0 then if mana.playerlist[name].remainder ~= nil then
local plus = mana.playerlist[name].regen * factor plus = plus + mana.playerlist[name].remainder
-- Compability check for version <= 1.0.2 which did not have the remainder field
if mana.playerlist[name].remainder ~= nil then
plus = plus + mana.playerlist[name].remainder
end
local plus_now = math.floor(plus)
local floor = plus - plus_now
if plus_now > 0 then
mana.add_up_to(name, plus_now)
else
mana.subtract_up_to(name, math.abs(plus_now))
end
mana.playerlist[name].remainder = floor
end end
local plus_now = math.floor(plus)
local floor = plus - plus_now
if plus_now > 0 then
mana.add_up_to(name, plus_now)
else
mana.subtract_up_to(name, math.abs(plus_now))
end
mana.playerlist[name].remainder = floor
end end
end end
mana.regen_timer = mana.regen_timer % mana.settings.regen_timer
end end
end) minetest.after(mana.settings.regen_timer, mana_regen_step)
end
minetest.after(0, mana_regen_step)
--[===[ --[===[
HUD functions HUD functions