2018-04-01 08:40:31 +02:00
|
|
|
--
|
|
|
|
-- Minetest cloaking mod: chat3 fixes
|
|
|
|
--
|
|
|
|
-- © 2018 by luk3yx
|
|
|
|
--
|
|
|
|
|
2018-04-01 09:03:13 +02:00
|
|
|
-- Override minetest.get_connected_players() so it lists cloaked players for
|
|
|
|
-- chat3.
|
2018-04-01 08:40:31 +02:00
|
|
|
local get_uncloaked_players = minetest.get_connected_players
|
|
|
|
|
|
|
|
minetest.get_connected_players = function()
|
|
|
|
local d = debug.getinfo(2)
|
2018-04-01 09:03:13 +02:00
|
|
|
if d.func == chat3.send or d.func == minetest.chatcommands['me'].func then
|
2018-04-01 08:40:31 +02:00
|
|
|
return cloaking.get_connected_players()
|
|
|
|
else
|
|
|
|
return get_uncloaked_players()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-04-01 09:03:13 +02:00
|
|
|
-- Override get_player_by_name() to allow chat3 to access cloaked players.
|
2018-04-01 08:40:31 +02:00
|
|
|
local get_uncloaked_player_by_name = minetest.get_player_by_name
|
|
|
|
|
|
|
|
minetest.get_player_by_name = function(player)
|
|
|
|
local d = debug.getinfo(2)
|
2018-04-01 09:03:13 +02:00
|
|
|
if d.func == chat3.send or d.func == minetest.chatcommands["me"].func then
|
2018-04-01 08:40:31 +02:00
|
|
|
return cloaking.get_player_by_name(player)
|
|
|
|
else
|
|
|
|
return get_uncloaked_player_by_name(player)
|
|
|
|
end
|
|
|
|
end
|
2018-04-01 09:03:13 +02:00
|
|
|
|
2018-10-11 01:11:57 +02:00
|
|
|
-- Override chat3.send() to add cloaking.on_chat_message().
|
2018-10-11 01:03:29 +02:00
|
|
|
local chat3_send = chat3.send
|
|
|
|
chat3.send = function(name, msg, ...)
|
|
|
|
if cloaking.on_chat_message(name, msg) then return true end
|
|
|
|
return chat3_send(name, msg, ...)
|
2018-04-01 09:03:13 +02:00
|
|
|
end
|