Guest User

Untitled

a guest
Oct 10th, 2017
11
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. minetest.register_on_joinplayer(function(player)
  2. player:set_hp(20)
  3. player:set_attribute("a:hp",100)
  4. end)
  5.  
  6. minetest.register_on_player_hpchange(function(player, hp_change)
  7.  
  8. if hp_change < 0 then
  9. local gethp = tonumber(player:get_attribute("a:hp"))
  10. local newhp = gethp + hp_change
  11. minetest.chat_send_all(newhp)
  12. player:set_attribute("a:hp",newhp)
  13.  
  14. if newhp <= 0 then
  15. player:set_attribute("a:hp",100)
  16. return -20
  17. end
  18.  
  19. end
  20.  
  21. if hp_change ~= 20 then
  22. return 0
  23. else
  24. return 20
  25. end
  26.  
  27. end, true)
RAW Paste Data