Epic/mods/maxhp/functions.lua

14 lines
421 B
Lua

function maxhp.max_hp_change(player, change, cap)
local cap = cap or 500
local name = player:get_player_name()
local max_hp = tonumber(maxhp.storage:get_string(name..'_max_hp'))
local new_max_hp = max_hp + change
if new_max_hp <= cap then
player:set_properties({hp_max = new_max_hp})
maxhp.storage:set_string(name..'_max_hp', new_max_hp)
return true
else
return false
end
end