Cleanup groups_to_items

This commit is contained in:
Jean-Patrick Guerrero 2020-07-18 01:39:12 +02:00
parent 74785bca5e
commit 1fb7790c4e

View File

@ -734,21 +734,17 @@ end
local function groups_to_items(groups, get_all) local function groups_to_items(groups, get_all)
if not get_all and #groups == 1 then if not get_all and #groups == 1 then
local group = groups[1] local group = groups[1]
local def_gr = "default:" .. group local stereotype = craftguide.group_stereotypes[group]
local stereotypes = craftguide.group_stereotypes local def = reg_items[stereotype]
local stereotype = stereotypes and stereotypes[group]
stereotype = reg_items[stereotype] and stereotype
if stereotype then if def and show_item(def) then
return stereotype return stereotype
elseif reg_items[def_gr] then
return def_gr
end end
end end
local names = {} local names = {}
for name, def in pairs(reg_items) do for name, def in pairs(reg_items) do
if item_has_groups(def.groups, groups) then if show_item(def) and item_has_groups(def.groups, groups) then
if get_all then if get_all then
names[#names + 1] = name names[#names + 1] = name
else else