Allow chatcommands to be disabled while cloaked.
This commit is contained in:
parent
30ae06ce57
commit
58a66942ef
|
@ -55,6 +55,8 @@ interact with them:
|
||||||
`cloaking.get_player_by_name`.
|
`cloaking.get_player_by_name`.
|
||||||
|
|
||||||
If you have made chatcommand work with players that aren't in-game, you can add
|
If you have made chatcommand work with players that aren't in-game, you can add
|
||||||
`_allow_while_cloaked = true` to the chatcommand definition. This does not
|
`_allow_while_cloaked = true` to the chatcommand definition. If you explicitly
|
||||||
require that you add `cloaking` to `depends.txt`, as when cloaking is not loaded
|
don't want your chatcommand working with cloaked players, you can add
|
||||||
this parameter is simply ignored.
|
`_disallow_while_cloaked = true` to the definition.
|
||||||
|
These modifications do not require that you add `cloaking` to `depends.txt`, as
|
||||||
|
when cloaking is not loaded this parameter is simply ignored.
|
||||||
|
|
16
core.lua
16
core.lua
|
@ -62,7 +62,12 @@ local override_chatcommands = function()
|
||||||
local real_cmd = def.func
|
local real_cmd = def.func
|
||||||
minetest.chatcommands[name].func = function(name, param)
|
minetest.chatcommands[name].func = function(name, param)
|
||||||
if cloaked_players[name] then
|
if cloaked_players[name] then
|
||||||
local pass, r1, r2 = pcall(real_cmd, name, param)
|
local pass, r1, r2
|
||||||
|
if def._disallow_while_cloaked then
|
||||||
|
pass = false
|
||||||
|
else
|
||||||
|
pass, r1, r2 = pcall(real_cmd, name, param)
|
||||||
|
end
|
||||||
if pass then
|
if pass then
|
||||||
return r1, r2
|
return r1, r2
|
||||||
else
|
else
|
||||||
|
@ -103,6 +108,15 @@ end
|
||||||
|
|
||||||
minetest.register_on_chat_message(cloaking.on_chat_message)
|
minetest.register_on_chat_message(cloaking.on_chat_message)
|
||||||
|
|
||||||
|
-- Disallow some built-in commands.
|
||||||
|
for _, cmd in ipairs({'me', 'msg', 'tell'}) do
|
||||||
|
if minetest.chatcommands[cmd] then
|
||||||
|
minetest.override_chatcommand(cmd, {
|
||||||
|
_disallow_while_cloaked = true
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- The cloak and uncloak functions
|
-- The cloak and uncloak functions
|
||||||
cloaking.cloak = function(player)
|
cloaking.cloak = function(player)
|
||||||
if not chatcommands_modified then override_chatcommands() end
|
if not chatcommands_modified then override_chatcommands() end
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
chat3?
|
chat3?
|
||||||
irc?
|
irc?
|
||||||
xban?
|
mesecons?
|
||||||
xban2?
|
|
||||||
|
|
Loading…
Reference in New Issue