From 460fd335ffa88cac1f1d4b55fabff4a6d3bd3978 Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Mon, 25 Jun 2018 00:01:27 +0100 Subject: [PATCH] Send kills to IRC channel --- mods/ctf_events/depends.txt | 1 + mods/ctf_events/init.lua | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/mods/ctf_events/depends.txt b/mods/ctf_events/depends.txt index c1955ae..bf1f229 100644 --- a/mods/ctf_events/depends.txt +++ b/mods/ctf_events/depends.txt @@ -1,2 +1,3 @@ ctf hudkit +irc? diff --git a/mods/ctf_events/init.lua b/mods/ctf_events/init.lua index f789aae..d485493 100644 --- a/mods/ctf_events/init.lua +++ b/mods/ctf_events/init.lua @@ -10,6 +10,27 @@ ctf_events = { events = {} } +local emoji = { + kill_bullet = ",-", + kill_grenade = "o'", + kill_sword = "+--", +} + +local function get_colorcodes(name) + if not name then + return "", "" + end + local color = ctf_colors.get_irc_color(name, ctf.player(name)) + local clear = "\x0F" + if color then + color = "\x03" .. color + else + color = "" + clear = "" + end + return color, clear +end + function ctf_events.post(action, one, two) table.insert(ctf_events.events, 1, { action = action, @@ -17,6 +38,16 @@ function ctf_events.post(action, one, two) two = two }) + if minetest.global_exists("irc") and emoji[action] then + local color1, clear1 = get_colorcodes(one) + local color2, clear2 = get_colorcodes(two) + local tag1 = one and (color1 .. "_" .. clear1) or "" + local tag2 = two and (color2 .. "_" .. clear2) or "" + local name1 = one and (tag1 .. one .. tag1) or "" + local name2 = two and (tag2 .. two .. tag2) or "" + irc.say((name1 .. " " .. emoji[action] .. " " .. name2):trim()) + end + while #ctf_events.events > NUM_EVT do table.remove(ctf_events.events, #ctf_events.events) end