Fix up medkit interrupt reasons (#734)
* Bugfix of "Add reason to medkit" * Fix reasons while attack and damage * Remove `die` reason, add `attack` reason * Change suggested code * Fix doc * fix line contains trailing whitespace * Update init.lua Co-authored-by: LoneWolfHT <lonewolf04361@gmail.com>
This commit is contained in:
parent
518e3f0807
commit
88c326f13d
1 changed files with 10 additions and 10 deletions
|
@ -47,17 +47,17 @@ local function start_healing(stack, player)
|
|||
end
|
||||
|
||||
|
||||
-- Interrupt reason can be:
|
||||
-- damage: get damage from another player
|
||||
-- move: move more then 1m
|
||||
-- die: die because any reason
|
||||
-- Interrupt reasons:
|
||||
-- attack: Attacked another player
|
||||
-- move: Moved 1m away from initial healing pos
|
||||
-- damage: Damaged by another player
|
||||
local function reason_handler(reason)
|
||||
if reason == "damage" then
|
||||
return " because someone damaged you!"
|
||||
if reason == "attack" then
|
||||
return " because you attacked other player!"
|
||||
elseif reason == "move" then
|
||||
return " because you moved!"
|
||||
elseif reason == "die" then
|
||||
return " because you died!"
|
||||
elseif reason == "damage" then
|
||||
return " because someone damaged you!"
|
||||
else
|
||||
return "!"
|
||||
end
|
||||
|
@ -132,12 +132,12 @@ end)
|
|||
minetest.register_on_player_hpchange(function(player, hp, reason)
|
||||
if hp < 0 then
|
||||
if players[player:get_player_name()] then
|
||||
stop_healing(player, "die")
|
||||
stop_healing(player, "damage")
|
||||
end
|
||||
if reason and reason.type == "punch" then
|
||||
local hitter = reason.object
|
||||
if hitter and players[hitter:get_player_name()] then
|
||||
stop_healing(hitter, "damage")
|
||||
stop_healing(hitter, "attack")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue