Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- minetest.register_on_player_hpchange(function(player, hp_change)
- local name = player:get_player_name()
- local oldhp = tonumber(player:get_attribute("hp:hp"))
- local newhp = 0
- newhp = oldhp + hp_change
- if newhp > maxhp[name] then
- newhp = maxhp[name]
- end
- if newhp <= 0 then
- newhp = maxhp[name]
- minetest.chat_send_player(name,"You died.")
- player:set_pos({x=0,y=0,z=0})
- --player:set_hp(0)
- minetest.log("action",name.." died")
- end
- minetest.log("action",name.." -> "..newhp.."/"..maxhp[name].." ("..hp_change..")")
- player:hud_change(hphuds[name], "text",newhp.." / "..maxhp[name])
- player:set_attribute("hp:hp",newhp)
- if hp_change ~= 20 then
- return 0
- else
- return 20
- end
- end, true)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement