Add general 'list' chat command

master
AntumDeluge 2017-08-03 12:49:55 -07:00
parent 5554b6380c
commit 6f47874e71
3 changed files with 38 additions and 10 deletions

View File

@ -5,16 +5,19 @@
### **Description:**
#### Chat Commands:
- ***listitems:*** Lists registered craft items available in the game.
- ***listentities:*** Lists registered entities available in the game.
- ***listores:*** Lists registered ores available in the game.
- Invocation: ```/<command> [options] [string1] [string2] ...```
- ***command:*** Name of the command (e.g. *listitems*, *listentities*, etc.)
- ***options:*** Switches to control output behavior.
- ***-v:*** Display description (if available) after object name
- ***string[1,2] ...:*** String parameter(s) to filter output.
- Without any string parameters, all objects registered in game are listed.
- With string parameters, only objects matching any of the strings will be listed.
- ***list:*** Lists registered items or entities available in the game.
- Invocation: ```/list type [options] [string1] [string2] ...```
- ***type:*** List type (e.g. "items", "entities", etc.) (currently, if omitted, defaults to "items").
- ***options:*** Switches to control output behavior.
- ***-v:*** Display description (if available) after object name.
- ***string[1,2] ...:*** String parameter(s) to filter output.
- Without any string parameters, all objects registered in game are listed.
- With string parameters, only objects matching any of the strings will be listed.
- ***listitems:*** Alias for */list items*.
- ***listentities:*** Alias for */list entities*.
- ***listores:*** Alias for */list ores*.
- Invocation: ```/<command> [options] [string1] [string2] ...```
- ***command:*** Name of the command (e.g. *listitems*, *listentities*, etc.)
![Screenshot](screenshot.png)

24
api.lua
View File

@ -411,3 +411,27 @@ registerChatCommand('listores', {
return listitems.list(player, params, switches, 'ores')
end,
})
--- General *list* chat command
--
-- @chatcmd list
-- @chatparam type
-- @chatparam [-v]
-- @chatparam [string1]
-- @chatparam [string2]
-- @chatparam ...
-- @treturn boolean
registerChatCommand('list', {
params = S('type') .. ' [-v] [' .. S('string1') .. '] [' .. S('string2') .. '] ...',
description = S('List registered items or entities'),
func = function(player, params)
local switches = string.split(params, ' ')
local l_type = table.remove(switches, 1)
switches = extractSwitches(switches)
params = removeListDuplicates(switches[2])
switches = switches[1]
return listitems.list(player, params, switches, l_type)
end,
})

View File

@ -7,6 +7,7 @@ List registered entities =
List registered ores =
## Help output parameters
type =
string1 =
string2 =