diff --git a/README.md b/README.md index 972de3c..aa9a3c5 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,8 @@ interact with them: `cloaking.get_player_by_name`. 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 -require that you add `cloaking` to `depends.txt`, as when cloaking is not loaded -this parameter is simply ignored. +`_allow_while_cloaked = true` to the chatcommand definition. If you explicitly +don't want your chatcommand working with cloaked players, you can add +`_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. diff --git a/core.lua b/core.lua index 9ba4e03..6b55368 100644 --- a/core.lua +++ b/core.lua @@ -62,7 +62,12 @@ local override_chatcommands = function() local real_cmd = def.func minetest.chatcommands[name].func = function(name, param) 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 return r1, r2 else @@ -103,6 +108,15 @@ end 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 cloaking.cloak = function(player) if not chatcommands_modified then override_chatcommands() end diff --git a/depends.txt b/depends.txt index 5111352..d0a051b 100644 --- a/depends.txt +++ b/depends.txt @@ -1,4 +1,3 @@ chat3? irc? -xban? -xban2? +mesecons?