aboutsummaryrefslogtreecommitdiff
path: root/builtin/common/chatcommands.lua
diff options
context:
space:
mode:
Diffstat (limited to 'builtin/common/chatcommands.lua')
-rw-r--r--builtin/common/chatcommands.lua76
1 files changed, 39 insertions, 37 deletions
diff --git a/builtin/common/chatcommands.lua b/builtin/common/chatcommands.lua
index 3d04391fb..709c3d00a 100644
--- a/builtin/common/chatcommands.lua
+++ b/builtin/common/chatcommands.lua
@@ -29,47 +29,49 @@ function core.override_chatcommand(name, redefinition)
core.registered_chatcommands[name] = chatcommand
end
-function core.register_list_command(command, desc, setting)
- local def = {}
- def.description = desc
- def.params = "del <item> | add <item> | list"
- function def.func(param)
- local list = (minetest.settings:get(setting) or ""):split(",")
- if param == "list" then
- return true, table.concat(list, ", ")
- else
- local sparam = param:split(" ")
- local cmd = sparam[1]
- local item = sparam[2]
- if cmd == "del" then
- if not item then
- return false, "Missing item."
- end
- local i = table.indexof(list, item)
- if i == -1 then
- return false, item .. " is not on the list."
- else
- table.remove(list, i)
- core.settings:set(setting, table.concat(list, ","))
- return true, "Removed " .. item .. " from the list."
- end
- elseif cmd == "add" then
- if not item then
- return false, "Missing item."
- end
- local i = table.indexof(list, item)
- if i ~= -1 then
- return false, item .. " is already on the list."
- else
- table.insert(list, item)
- core.settings:set(setting, table.concat(list, ","))
- return true, "Added " .. item .. " to the list."
+if INIT == "client" then
+ function core.register_list_command(command, desc, setting)
+ local def = {}
+ def.description = desc
+ def.params = "del <item> | add <item> | list"
+ function def.func(param)
+ local list = (minetest.settings:get(setting) or ""):split(",")
+ if param == "list" then
+ return true, table.concat(list, ", ")
+ else
+ local sparam = param:split(" ")
+ local cmd = sparam[1]
+ local item = sparam[2]
+ if cmd == "del" then
+ if not item then
+ return false, "Missing item."
+ end
+ local i = table.indexof(list, item)
+ if i == -1 then
+ return false, item .. " is not on the list."
+ else
+ table.remove(list, i)
+ core.settings:set(setting, table.concat(list, ","))
+ return true, "Removed " .. item .. " from the list."
+ end
+ elseif cmd == "add" then
+ if not item then
+ return false, "Missing item."
+ end
+ local i = table.indexof(list, item)
+ if i ~= -1 then
+ return false, item .. " is already on the list."
+ else
+ table.insert(list, item)
+ core.settings:set(setting, table.concat(list, ","))
+ return true, "Added " .. item .. " to the list."
+ end
end
end
+ return false, "Invalid usage. (See /help " .. command .. ")"
end
- return false, "Invalid usage. (See /help " .. command .. ")"
+ core.register_chatcommand(command, def)
end
- core.register_chatcommand(command, def)
end
local cmd_marker = "/"