diff --git a/README.md b/README.md index 3aa5d94e..28ba7788 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ The game includes the mods from the default [minetest_game](https://github.com/m * chat/ * [away][] ([GPL][lic.gpl2.0]) -- version: [4c1e5a9 Git][ver.away] *2012-03-09* ([patched][patch.away]) * [chatlog][] ([CC0][lic.cc0]) -- version: (no version info) *2013-06-09* ([patched][patch.chatlog]) - * [listitems][] ([MIT][lic.listitems]) -- version: [6aec9d7 Git][ver.listitems] *2017-06-15* + * [listitems][] ([MIT][lic.listitems]) -- version: [0.3 (48e0a64 Git)][ver.listitems] *2017-07-23* * crafting/ * [craftguide][] ([GPL / WTFPL](mods/crafting/craftguide/LICENSE)) -- version: [86a96c3 Git][ver.craftguide] *2017-03-21* ([patched][patch.craftguide]) * [currency][] ([WTFPL][lic.currency]) -- version: [3ee673d Git][ver.currency] *2017-05-18* ([patched][patch.currency]) @@ -465,7 +465,7 @@ The game includes the mods from the default [minetest_game](https://github.com/m [ver.invisibility]: https://github.com/tenplus1/invisibility/tree/bf4156b [ver.jukebox]: https://github.com/minetest-mods/jukebox/tree/e6a507f [ver.lightning]: https://github.com/minetest-mods/lightning/tree/39bd36c -[ver.listitems]: https://github.com/AntumMT/mod-listitems/tree/6aec9d7 +[ver.listitems]: https://github.com/AntumMT/mod-listitems/tree/48e0a64 [ver.mesecons]: https://github.com/minetest-mods/mesecons/tree/564bdc2 [ver.minetest_game]: https://github.com/minetest/minetest_game/tree/f855bee [ver.mob-engine]: https://github.com/minetest-mods/mob-engine/tree/138f655 diff --git a/mods/chat/listitems/README.md b/mods/chat/listitems/README.md new file mode 100644 index 00000000..256526e4 --- /dev/null +++ b/mods/chat/listitems/README.md @@ -0,0 +1,22 @@ +# ***listitems*** chat command for Minetest + + +### Description + +- A very basic chat command to list all registered craft items available in the game. +- Invocation: */listitems [string1] [string2] ...* + - Without any parameters, all items registered in game are listed. + - With parameters, only items matching any of the strings will be listed. + +![Screenshot](screenshot.png) + + +### Licensing + +- MIT (see [LICENSE.txt](LICENSE.txt)) + + +### Requirements + +- Depends: none +- Privileges: none diff --git a/mods/chat/listitems/register.lua b/mods/chat/listitems/api.lua similarity index 69% rename from mods/chat/listitems/register.lua rename to mods/chat/listitems/api.lua index 2443c7eb..4135511d 100644 --- a/mods/chat/listitems/register.lua +++ b/mods/chat/listitems/api.lua @@ -8,6 +8,23 @@ --]] +-- Boilerplate to support localized strings if intllib mod is installed. +local S +if minetest.global_exists('intllib') then + if intllib.make_gettext_pair then + S = intllib.make_gettext_pair() + else + S = intllib.Getter() + end +else + S = function(s) return s end +end + + +-- Invoking command string +local list_command = S('listitems') + + -- Retrieves a simplified table containing string names of registered items local function getRegisteredItemNames() local item_names = {} @@ -59,11 +76,11 @@ local function removeListDuplicates(tlist) end -minetest.log('action', '[listitems] Registering chat command "listitems"') +minetest.log('action', '[listitems] Registering chat command "' .. list_command .. '"') -minetest.register_chatcommand('listitems', { - params = '[string1] [string2] ...', - description = 'List registered items', +minetest.register_chatcommand(list_command, { + params = '[' .. S('string1') .. '] [' .. S('string2') .. '] ...', + description = S('List registered items'), func = function(player, param) -- Make all parameters lowercase for case-insensitive matching param = removeListDuplicates(string.split(string.lower(param), ' ')) @@ -85,11 +102,11 @@ minetest.register_chatcommand('listitems', { if found_names ~= nil then for I in pairs(found_names) do - minetest.chat_send_player(player, found_names[I]) + minetest.chat_send_player(player, S('•') .. ' ' .. found_names[I]) end - else - minetest.chat_send_player(player, 'No registered items found!') end + -- Show player number of items listed + minetest.chat_send_player(player, S('Items listed:') .. ' ' .. tostring(#found_names)) return true end, diff --git a/mods/chat/listitems/depends.txt b/mods/chat/listitems/depends.txt new file mode 100644 index 00000000..77e8d97c --- /dev/null +++ b/mods/chat/listitems/depends.txt @@ -0,0 +1 @@ +intllib? diff --git a/mods/chat/listitems/description.txt b/mods/chat/listitems/description.txt index c0491975..e9589832 100644 --- a/mods/chat/listitems/description.txt +++ b/mods/chat/listitems/description.txt @@ -1,3 +1,3 @@ -A very basic chat command to list all registered craft items availabe in the game. +A very basic chat command to list all registered craft items available in the game. -Use the command "/listitems [string1] [string2] ..." (no privileges required). \ No newline at end of file +Use the command "/listitems [string1] [string2] ..." (no privileges required). diff --git a/mods/chat/listitems/init.lua b/mods/chat/listitems/init.lua index 99a1be1d..e1551e4d 100644 --- a/mods/chat/listitems/init.lua +++ b/mods/chat/listitems/init.lua @@ -12,4 +12,4 @@ listitems = {} listitems.modname = minetest.get_current_modname() listitems.modpath = minetest.get_modpath(listitems.modname) -dofile(listitems.modpath .. '/register.lua') \ No newline at end of file +dofile(listitems.modpath .. '/api.lua') diff --git a/mods/chat/listitems/locale/es.txt b/mods/chat/listitems/locale/es.txt new file mode 100644 index 00000000..5312a272 --- /dev/null +++ b/mods/chat/listitems/locale/es.txt @@ -0,0 +1,15 @@ +# Translation by Jordan Irwin (AntumDeluge) + + +## Invoking command (remove this line to use default "listitems") +listitems = listararticulos + +## Help output description +List registered items = Listar los artículos registrados + +## Help output parameters +string1 = cadena1 +string2 = cadena2 + +## Number of items listed +Items listed: = Artículos enumerados: diff --git a/mods/chat/listitems/locale/template.txt b/mods/chat/listitems/locale/template.txt new file mode 100644 index 00000000..d6096831 --- /dev/null +++ b/mods/chat/listitems/locale/template.txt @@ -0,0 +1,18 @@ +# Translation by + + +## Invoking command (remove this line to use default "listitems") +listitems = + +## Help output description +List registered items = + +## Help output parameters +string1 = +string2 = + +## Number of items listed +Items listed: = + +## Bullet (change this if there are problems displaying the raw character "•") +• = diff --git a/mods/chat/listitems/mod.conf b/mods/chat/listitems/mod.conf index 9b429a27..4ed55b8b 100644 --- a/mods/chat/listitems/mod.conf +++ b/mods/chat/listitems/mod.conf @@ -2,4 +2,4 @@ name = listitems author = AntumDeluge description = Chat command that lists registered items. license = MIT -version = 0.1 \ No newline at end of file +version = 0.3 diff --git a/mods/chat/listitems/screenshot.png b/mods/chat/listitems/screenshot.png new file mode 100644 index 00000000..88a6388e Binary files /dev/null and b/mods/chat/listitems/screenshot.png differ