init.lua 865 B

1234567891011121314151617181920212223242526272829
  1. maxhp = {}
  2. maxhp.storage = minetest.get_mod_storage()
  3. dofile(minetest.get_modpath('maxhp')..'/functions.lua')
  4. dofile(minetest.get_modpath('maxhp')..'/potions.lua')
  5. minetest.register_on_joinplayer(function(player)
  6. local name = player:get_player_name()
  7. local max_hp = tonumber(maxhp.storage:get_string(name..'_max_hp'))
  8. if max_hp == nil then
  9. maxhp.storage:set_string(name..'_max_hp', 50)
  10. player:set_properties({hp_max = 50})
  11. else
  12. player:set_properties({hp_max = max_hp})
  13. end
  14. end)
  15. --[[
  16. minetest.register_on_dieplayer(function(player)
  17. local name = player:get_player_name()
  18. local max_hp = tonumber(maxhp.storage:get_string(name..'max_hp'))
  19. local new_max_hp = max_hp - 1
  20. if new_max_hp >= 25 then
  21. player:set_properties({hp_max = new_max_hp})
  22. maxhp.storage:set_string(name..'max_hp', new_max_hp)
  23. end
  24. end)
  25. --]]