Add hp regen (1 hp per 10 seconds)
This commit is contained in:
parent
84b81ad810
commit
36e76e7924
2 changed files with 22 additions and 0 deletions
|
@ -6,6 +6,8 @@ mgv6_spflags = nojungles, biomeblend, mudflow, nosnowbiomes, noflat
|
|||
map_generation_limit = 160
|
||||
vote.kick_vote = false
|
||||
barrier = 102
|
||||
regen_interval = 10
|
||||
regen_amount = 1
|
||||
|
||||
#
|
||||
# CTF_PVP_ENGINE
|
||||
|
|
20
mods/hpregen/init.lua
Normal file
20
mods/hpregen/init.lua
Normal file
|
@ -0,0 +1,20 @@
|
|||
local regen_interval = tonumber(minetest.setting_get("regen_interval"))
|
||||
if regen_interval <= 0 then
|
||||
regen_interval = 10
|
||||
end
|
||||
local regen_amount = tonumber(minetest.setting_get("regen_amount"))
|
||||
if regen_amount <= 0 then
|
||||
regen_amount = 1
|
||||
end
|
||||
|
||||
local function regen_all()
|
||||
for _, player in pairs(minetest.get_connected_players()) do
|
||||
local newhp = player:get_hp() + regen_amount
|
||||
if newhp > 20 then
|
||||
newhp = 20
|
||||
end
|
||||
player:set_hp(newhp)
|
||||
end
|
||||
minetest.after(regen_interval, regen_all)
|
||||
end
|
||||
minetest.after(regen_interval, regen_all)
|
Loading…
Reference in a new issue