Documentation changes
This commit is contained in:
parent
7d51481f23
commit
ce1481d3ed
27
README.md
27
README.md
@ -1,19 +1,20 @@
|
||||
# Subcommands
|
||||
this is a minetest API to creating commands with subcommands.
|
||||
## Method
|
||||
### `subcommands.register_command_with_subcommand(name.def)`
|
||||
same as `minetest.register_chatcommand`, but:
|
||||
- Don't fill anything in `func` def.
|
||||
- add `def._sc_def`(Dict)
|
||||
#### `def._sc_def`
|
||||
```
|
||||
This mod adds an API to create commands with subcommands.
|
||||
## Functions
|
||||
### `subcommands.register_command_with_subcommand(name, def)`
|
||||
The definition table is similar to the [Chat command definition for the Minetest API](https://minetest.gitlab.io/minetest/definition-tables/#chat-command-definition), except:
|
||||
* The `func` field should be left empty
|
||||
* The `_sc_def` field should be a table of subcommands. Each entry should be indexed by the name of the subcommand and have the following definition:
|
||||
```lua
|
||||
{
|
||||
subcommand_name = {
|
||||
description = "subcommand description"
|
||||
params = "<params>"
|
||||
description = "subcommand description",
|
||||
params = "<params>",
|
||||
privs = {required_privs = true}, -- Optional
|
||||
func = function(name,param) return true,"The function" end -- Just like func in minetest.register_chatcommand
|
||||
}
|
||||
}
|
||||
```
|
||||
The `help` subcommand is reserved and should not be used
|
||||
### `subcommands.subcommand_handler(sc_def,cm_name)`
|
||||
No usage
|
||||
Returns a handler for the command. This is mainly intended for internal use.
|
||||
* `sc_def`: subcommand definition (see above)
|
||||
* `cm_name`: name of the command
|
||||
|
Loading…
x
Reference in New Issue
Block a user