Commit 9d6e46bc authored by Milan's avatar Milan

attempt to make it compatible with matrix_chat

parent b84a287d
......@@ -53,6 +53,12 @@ local base = minetest.setting_get("color_boring")
local success = minetest.setting_get("color_success")
local failure = minetest.setting_get("color_failure")
if minetest.get_modpath("irc") then
bridge = 'irc'
elseif minetest.get_modpath('matrix_chat') then
bridge = 'matrix'
end
core.register_on_dieplayer(function(player)
local player_name = player:get_player_name()
local node = core.registered_nodes[core.get_node(player:getpos()).name]
......@@ -61,35 +67,25 @@ core.register_on_dieplayer(function(player)
end
-- Death by lava
if node.groups.lava ~= nil then
core.chat_send_all(core.colorize(failure, "- ") .. string.format(core.colorize(base, messages.lava[math.random(1,#messages.lava)]), player_name))
if minetest.get_modpath("irc") then
irc:say(string.format('*** %s died.', player_name))
end
core.chat_send_all(core.colorize(failure, "- ") .. string.format(core.colorize(base, messages.lava[math.random(1,#messages.lava)]), player_name))
bridge:say(string.format('*** %s died.', player_name))
-- Death by drowning
elseif player:get_breath() == 0 then
core.chat_send_all(core.colorize(failure, "- ") .. string.format(core.colorize(base, messages.water[math.random(1,#messages.water)]), player_name))
if minetest.get_modpath("irc") then
irc:say(string.format('*** %s died.', player_name))
end
bridge:say(string.format('*** %s died.', player_name))
-- Death by fire
elseif node.name == 'fire:basic_flame' then
core.chat_send_all(core.colorize(failure, "* ") .. string.format(core.colorize(base, messages.fire[math.random(1,#messages.fire)]), player_name))
if minetest.get_modpath("irc") then
irc:say(string.format('*** %s died.', player_name))
end
bridge:say(string.format('*** %s died.', player_name))
-- Death by something else
else
core.chat_send_all(core.colorize(failure, "- ") .. string.format(core.colorize(base, messages.other[math.random(1,#messages.other)]), player_name))
if minetest.get_modpath("irc") then
irc:say(string.format('*** %s died.', player_name))
end
end
bridge:say(string.format('*** %s died.', player_name))
end
end)
minetest.register_on_respawnplayer( function(player)
local player_name = player:get_player_name()
core.chat_send_all(core.colorize(success, "* ") .. string.format(core.colorize(base, messages.respawn[math.random(1,#messages.respawn)]), player_name))
if minetest.get_modpath("irc") then
irc:say(string.format('*** %s returns.', player_name))
end
bridge:say(string.format('*** %s returns.', player_name))
end)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment