2018-12-30 23:08:25 +00:00
|
|
|
local regen_interval = tonumber(minetest.settings:get("regen_interval"))
|
2016-01-02 14:08:40 +00:00
|
|
|
if regen_interval <= 0 then
|
2017-11-09 21:44:50 +00:00
|
|
|
regen_interval = 6
|
2016-01-02 14:08:40 +00:00
|
|
|
end
|
2018-12-30 23:08:25 +00:00
|
|
|
local regen_amount = tonumber(minetest.settings:get("regen_amount"))
|
2016-01-02 14:08:40 +00:00
|
|
|
if regen_amount <= 0 then
|
|
|
|
regen_amount = 1
|
|
|
|
end
|
|
|
|
|
|
|
|
local function regen_all()
|
|
|
|
for _, player in pairs(minetest.get_connected_players()) do
|
2016-01-05 02:57:10 +00:00
|
|
|
local oldhp = player:get_hp()
|
|
|
|
if oldhp > 0 then
|
|
|
|
local newhp = oldhp + regen_amount
|
|
|
|
if newhp > 20 then
|
|
|
|
newhp = 20
|
|
|
|
end
|
|
|
|
player:set_hp(newhp)
|
2016-01-02 14:08:40 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
minetest.after(regen_interval, regen_all)
|
|
|
|
end
|
|
|
|
minetest.after(regen_interval, regen_all)
|