Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/emojigit/subcommands
API to create minetest command with subcommand
https://github.com/emojigit/subcommands
Last synced: about 2 months ago
JSON representation
API to create minetest command with subcommand
- Host: GitHub
- URL: https://github.com/emojigit/subcommands
- Owner: Emojigit
- License: other
- Created: 2020-10-18T05:12:21.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2021-06-07T23:20:01.000Z (over 3 years ago)
- Last Synced: 2023-03-06T05:26:59.590Z (almost 2 years ago)
- Language: Lua
- Size: 21.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Subcommands
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
{
description = "subcommand description",
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)`
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