From 6cbc2e80ba7a3259e566989b5bb58708d3156a8f Mon Sep 17 00:00:00 2001 From: AntumDeluge Date: Thu, 15 Jun 2017 00:46:05 -0700 Subject: [PATCH] Replace 'antum_commands' with 'listitems' mod --- mods/antum/commands/depends.txt | 1 - mods/antum/commands/init.lua | 31 -------------- mods/antum/commands/mod.conf | 5 --- mods/chat/listitems/LICENSE.txt | 21 ++++++++++ .../listitems}/description.txt | 2 +- mods/chat/listitems/init.lua | 15 +++++++ mods/chat/listitems/mod.conf | 5 +++ .../listitems/register.lua} | 42 +++++-------------- 8 files changed, 53 insertions(+), 69 deletions(-) delete mode 100644 mods/antum/commands/depends.txt delete mode 100644 mods/antum/commands/init.lua delete mode 100644 mods/antum/commands/mod.conf create mode 100644 mods/chat/listitems/LICENSE.txt rename mods/{antum/commands => chat/listitems}/description.txt (51%) create mode 100644 mods/chat/listitems/init.lua create mode 100644 mods/chat/listitems/mod.conf rename mods/{antum/commands/list_items.lua => chat/listitems/register.lua} (50%) diff --git a/mods/antum/commands/depends.txt b/mods/antum/commands/depends.txt deleted file mode 100644 index a6cf431e..00000000 --- a/mods/antum/commands/depends.txt +++ /dev/null @@ -1 +0,0 @@ -antum diff --git a/mods/antum/commands/init.lua b/mods/antum/commands/init.lua deleted file mode 100644 index 5712171e..00000000 --- a/mods/antum/commands/init.lua +++ /dev/null @@ -1,31 +0,0 @@ ---[[ LICENSE HEADER - - MIT License - - Copyright © 2017 Jordan Irwin - - Permission is hereby granted, free of charge, to any person obtaining a copy of - this software and associated documentation files (the "Software"), to deal in - the Software without restriction, including without limitation the rights to - use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - of the Software, and to permit persons to whom the Software is furnished to do - so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. - ---]] - - -antum.list_items = {} - - -antum.loadScript('list_items') diff --git a/mods/antum/commands/mod.conf b/mods/antum/commands/mod.conf deleted file mode 100644 index 953d642b..00000000 --- a/mods/antum/commands/mod.conf +++ /dev/null @@ -1,5 +0,0 @@ -name = antum_commands -author = AntumDeluge -description = Custom commands for the Antum game. -license = MIT -version = 0.1 \ No newline at end of file diff --git a/mods/chat/listitems/LICENSE.txt b/mods/chat/listitems/LICENSE.txt new file mode 100644 index 00000000..db11a470 --- /dev/null +++ b/mods/chat/listitems/LICENSE.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright © 2017 Jordan Irwin + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/mods/antum/commands/description.txt b/mods/chat/listitems/description.txt similarity index 51% rename from mods/antum/commands/description.txt rename to mods/chat/listitems/description.txt index c8a5bc34..c0491975 100644 --- a/mods/antum/commands/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. -Use the command "/listitems" (no privileges required). +Use the command "/listitems [string1] [string2] ..." (no privileges required). \ No newline at end of file diff --git a/mods/chat/listitems/init.lua b/mods/chat/listitems/init.lua new file mode 100644 index 00000000..99a1be1d --- /dev/null +++ b/mods/chat/listitems/init.lua @@ -0,0 +1,15 @@ +--[[ LICENSE HEADER + + MIT Licensing + + Copyright © 2017 Jordan Irwin + + See: LICENSE.txt +--]] + + +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 diff --git a/mods/chat/listitems/mod.conf b/mods/chat/listitems/mod.conf new file mode 100644 index 00000000..9b429a27 --- /dev/null +++ b/mods/chat/listitems/mod.conf @@ -0,0 +1,5 @@ +name = listitems +author = AntumDeluge +description = Chat command that lists registered items. +license = MIT +version = 0.1 \ No newline at end of file diff --git a/mods/antum/commands/list_items.lua b/mods/chat/listitems/register.lua similarity index 50% rename from mods/antum/commands/list_items.lua rename to mods/chat/listitems/register.lua index c8792b54..ceaa4cdf 100644 --- a/mods/antum/commands/list_items.lua +++ b/mods/chat/listitems/register.lua @@ -1,32 +1,15 @@ --[[ LICENSE HEADER - MIT License + MIT Licensing Copyright © 2017 Jordan Irwin - Permission is hereby granted, free of charge, to any person obtaining a copy of - this software and associated documentation files (the "Software"), to deal in - the Software without restriction, including without limitation the rights to - use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies - of the Software, and to permit persons to whom the Software is furnished to do - so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. - + See: LICENSE.txt --]] -- Retrieves a simplified table containing string names of registered items -function antum.getRegisteredItemNames() +local function getRegisteredItemNames() local item_names = {} for item, def in pairs(minetest.registered_items) do table.insert(item_names, item) @@ -39,8 +22,7 @@ end -- Compares a string from a list of substrings --- FIXME: Move to Antum functions -function antum.compareSubstringList(ss_list, s_value) +local function compareSubstringList(ss_list, s_value) for index, substring in ipairs(ss_list) do -- Tests for substring (does not need to match full string) if string.find(s_value, substring) then @@ -53,8 +35,7 @@ end -- Checks if value is contained in list --- FIXME: Move to Antum functions -function antum.listContains(tlist, v) +local function listContains(tlist, v) for index, value in ipairs(tlist) do if v == value then return true @@ -66,8 +47,7 @@ end -- Replaces duplicates found in a list --- FIXME: Move to Antum functions -function antum.removeListDuplicates(tlist) +local function removeListDuplicates(tlist) local cleaned = {} for index, value in ipairs(tlist) do if not antum.listContains(cleaned, value) then @@ -79,16 +59,16 @@ function antum.removeListDuplicates(tlist) end -antum.logAction('Registering chat command "listitems"') +minetest.log('action', '[listitems] Registering chat command "listitems"') minetest.register_chatcommand('listitems', { params = '[string1] [string2] ...', description = 'List registered items', func = function(player, param) -- Make all parameters lowercase for case-insensitive matching - param = antum.removeListDuplicates(string.split(string.lower(param), ' ')) + param = removeListDuplicates(string.split(string.lower(param), ' ')) - local all_item_names = antum.getRegisteredItemNames() + local all_item_names = getRegisteredItemNames() local found_names = {} -- Check if table is empty @@ -97,7 +77,7 @@ minetest.register_chatcommand('listitems', { else -- Need to fill item list for I in pairs(all_item_names) do - if antum.compareSubstringList(param, string.lower(all_item_names[I])) then + if compareSubstringList(param, string.lower(all_item_names[I])) then table.insert(found_names, all_item_names[I]) end end @@ -113,4 +93,4 @@ minetest.register_chatcommand('listitems', { return true end, -}) +}) \ No newline at end of file