forked from VoxeLibre/VoxeLibre
Add regeneration
This commit is contained in:
parent
d9e78e8ad9
commit
3ab5035312
|
@ -72,9 +72,16 @@ function mcl_potions.poison_func(player, factor, duration)
|
||||||
end
|
end
|
||||||
|
|
||||||
function mcl_potions.regeneration_func(player, factor, duration)
|
function mcl_potions.regeneration_func(player, factor, duration)
|
||||||
player:set_attribute("regeneration", tostring(factor))
|
if minetest.is_player(player) then
|
||||||
print(player:get_player_name().." ".."regeneration = "..player:get_attribute("regeneration"))
|
|
||||||
minetest.after(duration, function() player:set_attribute("regeneration", tostring(0)) end )
|
for i=1,math.floor(duration/factor) do
|
||||||
|
minetest.after(i*factor, function()
|
||||||
|
if player:get_hp() < 20 then
|
||||||
|
player:set_hp(player:get_hp() + 0.5)
|
||||||
|
end
|
||||||
|
end )
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function mcl_potions.invisiblility_func(player, duration)
|
function mcl_potions.invisiblility_func(player, duration)
|
||||||
|
@ -86,7 +93,11 @@ function mcl_potions.water_breathing_func(player, duration)
|
||||||
if minetest.is_player(player) then
|
if minetest.is_player(player) then
|
||||||
|
|
||||||
for i=1,math.floor(duration) do
|
for i=1,math.floor(duration) do
|
||||||
minetest.after(i, function() player:set_breath(10) end )
|
minetest.after(i, function()
|
||||||
|
if player:get_breath() < 10 then
|
||||||
|
player:set_breath(10)
|
||||||
|
end
|
||||||
|
end )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -466,13 +466,13 @@ minetest.register_craftitem("mcl_potions:regeneration_2", {
|
||||||
stack_max = 1,
|
stack_max = 1,
|
||||||
|
|
||||||
on_place = function(itemstack, user, pointed_thing)
|
on_place = function(itemstack, user, pointed_thing)
|
||||||
mcl_potions.regeneration_func(user, 1.2, 21)
|
mcl_potions.regeneration_func(user, 1.2, 22)
|
||||||
mcl_potions._use_potion(itemstack)
|
mcl_potions._use_potion(itemstack)
|
||||||
return itemstack
|
return itemstack
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_secondary_use = function(itemstack, user, pointed_thing)
|
on_secondary_use = function(itemstack, user, pointed_thing)
|
||||||
mcl_potions.regeneration_func(user, 1.2, 21)
|
mcl_potions.regeneration_func(user, 1.2, 22)
|
||||||
mcl_potions._use_potion(itemstack)
|
mcl_potions._use_potion(itemstack)
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue