Advertisement
Guest User

Untitled

a guest
Sep 7th, 2017
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.69 KB | None | 0 0
  1. minetest.register_on_player_hpchange(function(player, hp_change)
  2.  
  3. local name = player:get_player_name()
  4. local oldhp = tonumber(player:get_attribute("hp:hp"))
  5. local newhp = 0
  6.  
  7. newhp = oldhp + hp_change
  8.  
  9. if newhp > maxhp[name] then
  10. newhp = maxhp[name]
  11. end
  12.  
  13. if newhp <= 0 then
  14. newhp = maxhp[name]
  15. minetest.chat_send_player(name,"You died.")
  16. player:set_pos({x=0,y=0,z=0})
  17. --player:set_hp(0)
  18. minetest.log("action",name.." died")
  19. end
  20.  
  21. minetest.log("action",name.." -> "..newhp.."/"..maxhp[name].." ("..hp_change..")")
  22. player:hud_change(hphuds[name], "text",newhp.." / "..maxhp[name])
  23. player:set_attribute("hp:hp",newhp)
  24.  
  25. if hp_change ~= 20 then
  26. return 0
  27. else
  28. return 20
  29. end
  30.  
  31. end, true)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement