Guest User

Untitled

a guest
Oct 10th, 2017
22
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.     end
  19.  
  20.     if hp_change ~= 20 then
  21.         return 0
  22.     else
  23.         return 20
  24.     end
  25.  
  26. end, true)
RAW Paste Data