From 88c326f13d4d064ba43854783856422b6919bb07 Mon Sep 17 00:00:00 2001 From: Emojigit <55009343+Emojigit@users.noreply.github.com> Date: Wed, 6 Jan 2021 11:56:55 +0800 Subject: [PATCH] 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 --- mods/pvp/medkits/init.lua | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/mods/pvp/medkits/init.lua b/mods/pvp/medkits/init.lua index c3c874c..92ee651 100644 --- a/mods/pvp/medkits/init.lua +++ b/mods/pvp/medkits/init.lua @@ -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