attempt to make it compatible with matrix_chat

master
tchncs 2018-08-23 16:17:56 +02:00
parent b84a287ddd
commit 9d6e46bcb5
1 changed files with 13 additions and 17 deletions

View File

@ -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)