aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCora de la Mouche <73539712+corarona@users.noreply.github.com>2023-06-23 18:26:33 +0200
committerGitHub <noreply@github.com>2023-06-23 18:26:33 +0200
commit6df1590803bf89eca455238aae006a74c98b8ce2 (patch)
tree346ed64889b69f3c1e52985b0e0166fa4685c5ff
parent2c050a42d7d4c33552834a219fb8247b7e70a69e (diff)
downloaddragonfireclient-6df1590803bf89eca455238aae006a74c98b8ce2.tar.xz
Add list setting -> chatcmd def for external access (#62)HEADmaster
* Add list setting -> chatcmd def for external access * Document the _list_setting field ... in both the chatcmd def and minetest.register_list_command * doc: add missing 'by' * remove underscore (_list_setting -> list_setting) --------- Co-authored-by: Lizzy Fleckenstein <eliasfleckenstein@web.de>
-rw-r--r--builtin/common/chatcommands.lua1
-rw-r--r--doc/client_lua_api.txt3
2 files changed, 4 insertions, 0 deletions
diff --git a/builtin/common/chatcommands.lua b/builtin/common/chatcommands.lua
index 817f1f526..cf20ec0d8 100644
--- a/builtin/common/chatcommands.lua
+++ b/builtin/common/chatcommands.lua
@@ -74,6 +74,7 @@ if INIT == "client" then
local def = {}
def.description = desc
def.params = "del <item> | add <item> | list"
+ def.list_setting = setting
function def.func(param)
local list = (minetest.settings:get(setting) or ""):split(",")
if param == "list" then
diff --git a/doc/client_lua_api.txt b/doc/client_lua_api.txt
index 108cd2fa8..afdd2f319 100644
--- a/doc/client_lua_api.txt
+++ b/doc/client_lua_api.txt
@@ -712,6 +712,8 @@ Call these functions only at load time!
* `add` adds something to the list
* `del` del removes something from the list
* `list` lists all items on the list
+ * The field `list_setting` will be set in the chatcommand definition to be able to recover it the
+ value of the 3rd parameter (settings) from minetest.registered_chatcommands later.
* `minetest.register_on_chatcommand(function(command, params))`
* Called always when a chatcommand is triggered, before `minetest.registered_chatcommands`
is checked to see if that the command exists, but after the input is parsed.
@@ -1632,6 +1634,7 @@ It can be created via `Raycast(pos1, pos2, objects, liquids)` or
description = "Remove privilege from player", -- Full description
func = function(param), -- Called when command is run.
-- Returns boolean success and text output.
+ list_setting, -- this field will be automatically set by the minetest.register_list_command reflecting the 3rd "setting" parameter
}
### Server info
```lua