diff --git a/README.md b/README.md index 4e2a715..1efd25e 100644 --- a/README.md +++ b/README.md @@ -7,10 +7,11 @@ #### 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: ```/ [options] [string1] [string2] ...``` - - ***command:*** Name of the command (e.g. *listitems*, *listentities*) + - ***command:*** Name of the command (e.g. *listitems*, *listentities*, etc.) - ***options:*** Switches to control output behavior. - - ***-v:*** Display description after object name + - ***-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. diff --git a/api.lua b/api.lua index 2d5e046..a0ad3ea 100644 --- a/api.lua +++ b/api.lua @@ -71,23 +71,30 @@ end -- @function getRegistered -- @local -- @tparam string r_type Must be either "items" or "entities". --- @treturn table Either a list of registered item or entity names & descriptions. +-- @treturn table Either a list of registered item or entity names & descriptions. +-- @note Ore names are located in the "ore" field of the registered tables local function getRegistered(r_type) - if r_type == nil then - r_type = 'items' - end + -- Default is "items" + r_type = r_type or 'items' local o_names = {} local objects = {} local o_temp = {} - if r_type == 'items' then - o_temp = core.registered_items - else + if r_type == 'entities' then o_temp = core.registered_entities + elseif r_type == 'ores' then + o_temp = core.registered_ores + else + o_temp = core.registered_items end for name, def in pairs(o_temp) do + -- Ore names are located in the 'ore' field of the table + if r_type == 'ores' then + name = def.ore + end + table.insert(objects, {name=name, descr=def.description,}) table.insert(o_names, name) end @@ -294,7 +301,7 @@ end -- @tparam string player Name of player to receive message output. -- @tparam string params String list of parameters. -- @tparam string switches String list of switch options for manipulating output. --- @tparam string l_type Objects to list (either "items" or "entities"). +-- @tparam string l_type Objects to list (either "items", "entities", or "ores"). -- @tparam boolean lower Case-insensitive matching if ***true***. -- @treturn boolean function listitems.list(player, params, switches, l_type, lower) @@ -302,7 +309,7 @@ function listitems.list(player, params, switches, l_type, lower) l_type = l_type or 'items' lower = lower == nil or lower == true - local types = {'items', 'entities',} + local types = {'items', 'entities', 'ores',} if not listContains(types, l_type) then listitems.logWarn('listitems.listitems called with unknown list type: ' .. tostring(l_type)) return false @@ -383,3 +390,24 @@ registerChatCommand('listentities', { return listitems.list(player, params, switches, 'entities') end, }) + + +--- Lists registered ores. +-- +-- @chatcmd listores +-- @chatparam [-v] +-- @chatparam [string1] +-- @chatparam [string2] +-- @chatparam ... +-- @treturn boolean +registerChatCommand('listores', { + params = '[-v] [' .. S('string1') .. '] [' .. S('string2') .. '] ...', + description = S('List registered ores'), + func = function(player, params) + local switches = extractSwitches(string.split(params, ' ')) + params = removeListDuplicates(switches[2]) + switches = switches[1] + + return listitems.list(player, params, switches, 'ores') + end, +}) diff --git a/docs/config.ld b/docs/config.ld index ebf5e24..f892766 100644 --- a/docs/config.ld +++ b/docs/config.ld @@ -5,7 +5,7 @@ not_luadoc = true --wrap = true boilerplate = true -local function tagoutput(value) +local function italic(value) return '' .. value .. '' end @@ -13,11 +13,11 @@ new_type('setting', 'Settings') new_type('chatcmd', 'Chat Commands', false, 'chatparam') custom_tags = { {'default', - format = tagoutput, + format = italic, }, {'type2', title = 'Type', - format = tagoutput, + format = italic, }, {'dfield', title = 'Definition Fields', @@ -38,14 +38,14 @@ custom_tags = { }, {'settype', title = 'Type', - format = function(item) - return '' .. item .. '' - end, - } + format = italic, + }, + {'note', + title = 'Notes', + format = italic, + }, } -alias('tchatparam', 'chatparam') - local function chatcmd_handler(item) local output = item.name for i, p in ipairs(item.tags.chatparam) do diff --git a/locale/template.txt b/locale/template.txt index 7f3fa87..79a664c 100644 --- a/locale/template.txt +++ b/locale/template.txt @@ -4,6 +4,7 @@ ## Help output description List registered items = List registered entities = +List registered ores = ## Help output parameters options =