From f1bc56f4cda629d3a66147172227f7db57774594 Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Tue, 5 Apr 2016 17:15:59 +0100 Subject: [PATCH] Give kill type to on_killedplayer, and fix crash in ctf_colors.get_color() --- ctf/teams.lua | 13 ++++++++++++- ctf_colors/hud.lua | 6 +++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/ctf/teams.lua b/ctf/teams.lua index 4f7c41c..b832975 100644 --- a/ctf/teams.lua +++ b/ctf/teams.lua @@ -449,8 +449,19 @@ minetest.register_on_punchplayer(function(player, hitter, end if player:get_hp() - damage <= 0 then + local wielded = hitter:get_wielded_item() + local wname = wielded:get_name() + print(wname) + local type = "sword" + if wname:sub(1, 8) == "shooter:" then + if wname == "shooter:grenade" then + type = "grenade" + else + type = "bullet" + end + end for i = 1, #ctf.registered_on_killedplayer do - ctf.registered_on_killedplayer[i](player:get_player_name(), hitter:get_player_name()) + ctf.registered_on_killedplayer[i](player:get_player_name(), hitter:get_player_name(), type) end return false end diff --git a/ctf_colors/hud.lua b/ctf_colors/hud.lua index c1004f9..b7e510f 100644 --- a/ctf_colors/hud.lua +++ b/ctf_colors/hud.lua @@ -1,5 +1,9 @@ function ctf_colors.get_color(name, tplayer) - local tcolor_text = ctf.team(tplayer.team).data.color + local team = ctf.team(tplayer.team) + local tcolor_text = nil + if team then + tcolor_text = team.data.color + end local tcolor_hex = ctf.flag_colors[tcolor_text] if not tcolor_hex then tcolor_hex = "0x000000"