1234567891011121314151617181920212223242526272829303132333435 |
- local damage_cooldowns = {}
- minetest.register_globalstep(function(dtime)
- for name, cd in pairs(damage_cooldowns)
- do
- cd = cd - dtime
- if cd <= 0
- then
- damage_coooldowns[name] = nil
- else
- damage_cooldowns[name] = c
- end
-
- end
- end)
- minetest.register_on_player_hpchange(function(player, change, reason)
- if reason.type == "punch"
- then
- local name = player:get_player_name()
- if damage_cooldowns[name]
- then
- return 0
- else
- damage_cooldowns[name] = 0.1
- return change
- end
- elseif reason.type == "fall"
- then
- return 0
- end
- return change
- end, true)
|