Can disable command result printing

master
Wuzzy 2020-11-18 15:53:55 +01:00
parent 9152e07b60
commit ca62e50f38
2 changed files with 20 additions and 7 deletions

View File

@ -5,6 +5,8 @@ local NEWLINE = "\n"
local DESCRIPTION = S("Command Tool")
local MAX_CMD_TOOLTIP_LEN = 48
local print_result = minetest.settings:get_bool("cmdtool_print_result", true)
local split_commands = function(commands_string)
return string.split(commands_string, NEWLINE)
end
@ -120,15 +122,24 @@ local execute_command = function(itemstack, player, pointed_thing)
local retval, msg = def.func(player_name, cmd_params)
-- Print return value and message
if retval == true then
minetest.chat_send_player(player_name, minetest.colorize("#00FF00", "["..S("OK").."] ".. cmd))
elseif retval == false then
minetest.chat_send_player(player_name, minetest.colorize("#FF0000", "["..S("FAIL").."] ".. cmd))
elseif retval == nil then
minetest.chat_send_player(player_name, minetest.colorize("#FF8800", "["..S("UNKN").."] ".. cmd))
if print_result then
if retval == true then
-- Command successfull
minetest.chat_send_player(player_name, minetest.colorize("#00FF00", "["..S("OK").."] ".. cmd))
elseif retval == false then
-- Command failed
minetest.chat_send_player(player_name, minetest.colorize("#FF0000", "["..S("FAIL").."] ".. cmd))
elseif retval == nil then
-- Command result unknown
minetest.chat_send_player(player_name, minetest.colorize("#FF8800", "["..S("UNKN").."] ".. cmd))
end
end
if msg ~= nil and msg ~= "" then
minetest.chat_send_player(player_name, "> " .. msg)
local out = msg
if print_result then
local out = "> " .. msg
end
minetest.chat_send_player(player_name, out)
end
else
minetest.chat_send_player(player_name, minetest.colorize("#FF0000", S("Nothing pointed!")))

2
settingtypes.txt Normal file
View File

@ -0,0 +1,2 @@
# If enabled, the command and the result of the command will be shown in chat whenever a command tool is used.
cmdtool_print_result (Show command result) bool true