Skip to content

Commit

Permalink
Add hp regen (1 hp per 10 seconds)
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenwardy committed Jan 2, 2016
1 parent 84b81ad commit 36e76e7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions minetest.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 20 additions & 0 deletions mods/hpregen/init.lua
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 36e76e7

Please sign in to comment.