functions.lua 421 B

1234567891011121314
  1. function maxhp.max_hp_change(player, change, cap)
  2. local cap = cap or 500
  3. local name = player:get_player_name()
  4. local max_hp = tonumber(maxhp.storage:get_string(name..'_max_hp'))
  5. local new_max_hp = max_hp + change
  6. if new_max_hp <= cap then
  7. player:set_properties({hp_max = new_max_hp})
  8. maxhp.storage:set_string(name..'_max_hp', new_max_hp)
  9. return true
  10. else
  11. return false
  12. end
  13. end