Can disable command result printing
parent
9152e07b60
commit
ca62e50f38
13
init.lua
13
init.lua
|
@ -5,6 +5,8 @@ local NEWLINE = "\n"
|
||||||
local DESCRIPTION = S("Command Tool")
|
local DESCRIPTION = S("Command Tool")
|
||||||
local MAX_CMD_TOOLTIP_LEN = 48
|
local MAX_CMD_TOOLTIP_LEN = 48
|
||||||
|
|
||||||
|
local print_result = minetest.settings:get_bool("cmdtool_print_result", true)
|
||||||
|
|
||||||
local split_commands = function(commands_string)
|
local split_commands = function(commands_string)
|
||||||
return string.split(commands_string, NEWLINE)
|
return string.split(commands_string, NEWLINE)
|
||||||
end
|
end
|
||||||
|
@ -120,15 +122,24 @@ local execute_command = function(itemstack, player, pointed_thing)
|
||||||
local retval, msg = def.func(player_name, cmd_params)
|
local retval, msg = def.func(player_name, cmd_params)
|
||||||
|
|
||||||
-- Print return value and message
|
-- Print return value and message
|
||||||
|
if print_result then
|
||||||
if retval == true then
|
if retval == true then
|
||||||
|
-- Command successfull
|
||||||
minetest.chat_send_player(player_name, minetest.colorize("#00FF00", "["..S("OK").."] ".. cmd))
|
minetest.chat_send_player(player_name, minetest.colorize("#00FF00", "["..S("OK").."] ".. cmd))
|
||||||
elseif retval == false then
|
elseif retval == false then
|
||||||
|
-- Command failed
|
||||||
minetest.chat_send_player(player_name, minetest.colorize("#FF0000", "["..S("FAIL").."] ".. cmd))
|
minetest.chat_send_player(player_name, minetest.colorize("#FF0000", "["..S("FAIL").."] ".. cmd))
|
||||||
elseif retval == nil then
|
elseif retval == nil then
|
||||||
|
-- Command result unknown
|
||||||
minetest.chat_send_player(player_name, minetest.colorize("#FF8800", "["..S("UNKN").."] ".. cmd))
|
minetest.chat_send_player(player_name, minetest.colorize("#FF8800", "["..S("UNKN").."] ".. cmd))
|
||||||
end
|
end
|
||||||
|
end
|
||||||
if msg ~= nil and msg ~= "" then
|
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
|
end
|
||||||
else
|
else
|
||||||
minetest.chat_send_player(player_name, minetest.colorize("#FF0000", S("Nothing pointed!")))
|
minetest.chat_send_player(player_name, minetest.colorize("#FF0000", S("Nothing pointed!")))
|
||||||
|
|
|
@ -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
|
Loading…
Reference in New Issue