From 8555f75acc050f29508d88f1e57159f79cb948d1 Mon Sep 17 00:00:00 2001 From: Vanessa Dannenberg Date: Mon, 1 Apr 2019 19:38:47 -0400 Subject: update blox, castles, cottages, technic, farming_redo, gloopblocks, homedecor, led_marquee, locks, maptools, mesecons, plantlife, moreblocks, nixie_tubes, replacer, travelnet, and unified inventory --- unified_inventory/group.lua | 40 +++++++++++++++------------------------- 1 file changed, 15 insertions(+), 25 deletions(-) (limited to 'unified_inventory/group.lua') diff --git a/unified_inventory/group.lua b/unified_inventory/group.lua index 23e2587..c7e09be 100644 --- a/unified_inventory/group.lua +++ b/unified_inventory/group.lua @@ -2,19 +2,21 @@ local S = unified_inventory.gettext function unified_inventory.canonical_item_spec_matcher(spec) local specname = ItemStack(spec):get_name() - if specname:sub(1, 6) == "group:" then - local group_names = specname:sub(7):split(",") + if specname:sub(1, 6) ~= "group:" then return function (itemname) - local itemdef = minetest.registered_items[itemname] - for _, group_name in ipairs(group_names) do - if (itemdef.groups[group_name] or 0) == 0 then - return false - end + return itemname == specname + end + end + + local group_names = specname:sub(7):split(",") + return function (itemname) + local itemdef = minetest.registered_items[itemname] + for _, group_name in ipairs(group_names) do + if (itemdef.groups[group_name] or 0) == 0 then + return false end - return true end - else - return function (itemname) return itemname == specname end + return true end end @@ -25,23 +27,11 @@ end function unified_inventory.extract_groupnames(groupname) local specname = ItemStack(groupname):get_name() - if specname:sub(1, 6) == "group:" then - local group_names = specname:sub(7):split(",") - if #group_names == 1 then - return group_names[1], 1 - end - local s = "" - for g=1,#group_names do - if g > 1 then - -- List connector - s = s .. S(" and ") - end - s = s .. group_names[g] - end - return s, #group_names - else + if specname:sub(1, 6) ~= "group:" then return nil, 0 end + local group_names = specname:sub(7):split(",") + return table.concat(group_names, S(" and ")), #group_names end unified_inventory.registered_group_items = { -- cgit v1.2.3