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
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Interrupt reason can be:
|
-- Interrupt reasons:
|
||||||
-- damage: get damage from another player
|
-- attack: Attacked another player
|
||||||
-- move: move more then 1m
|
-- move: Moved 1m away from initial healing pos
|
||||||
-- die: die because any reason
|
-- damage: Damaged by another player
|
||||||
local function reason_handler(reason)
|
local function reason_handler(reason)
|
||||||
if reason == "damage" then
|
if reason == "attack" then
|
||||||
return " because someone damaged you!"
|
return " because you attacked other player!"
|
||||||
elseif reason == "move" then
|
elseif reason == "move" then
|
||||||
return " because you moved!"
|
return " because you moved!"
|
||||||
elseif reason == "die" then
|
elseif reason == "damage" then
|
||||||
return " because you died!"
|
return " because someone damaged you!"
|
||||||
else
|
else
|
||||||
return "!"
|
return "!"
|
||||||
end
|
end
|
||||||
|
@ -132,12 +132,12 @@ end)
|
||||||
minetest.register_on_player_hpchange(function(player, hp, reason)
|
minetest.register_on_player_hpchange(function(player, hp, reason)
|
||||||
if hp < 0 then
|
if hp < 0 then
|
||||||
if players[player:get_player_name()] then
|
if players[player:get_player_name()] then
|
||||||
stop_healing(player, "die")
|
stop_healing(player, "damage")
|
||||||
end
|
end
|
||||||
if reason and reason.type == "punch" then
|
if reason and reason.type == "punch" then
|
||||||
local hitter = reason.object
|
local hitter = reason.object
|
||||||
if hitter and players[hitter:get_player_name()] then
|
if hitter and players[hitter:get_player_name()] then
|
||||||
stop_healing(hitter, "damage")
|
stop_healing(hitter, "attack")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue