Minor cleanup
This commit is contained in:
parent
797db59345
commit
7c9785d448
22
init.lua
22
init.lua
|
@ -795,21 +795,18 @@ local function search(data)
|
||||||
data.items = filtered_list
|
data.items = filtered_list
|
||||||
end
|
end
|
||||||
|
|
||||||
local function get_usages(recipe)
|
local function get_item_usages(item, recipe, added)
|
||||||
local added = {}
|
|
||||||
|
|
||||||
for _, item in pairs(recipe.items) do
|
|
||||||
item = reg_aliases[item] or item
|
|
||||||
if not added[item] then
|
|
||||||
local groups = extract_groups(item)
|
local groups = extract_groups(item)
|
||||||
|
|
||||||
if groups then
|
if groups then
|
||||||
for name, def in pairs(reg_items) do
|
for name, def in pairs(reg_items) do
|
||||||
if not added[name] and show_item(def) and
|
if not added[name] and show_item(def) and item_has_groups(def.groups, groups) then
|
||||||
item_has_groups(def.groups, groups) then
|
|
||||||
local usage = copy(recipe)
|
local usage = copy(recipe)
|
||||||
table_replace(usage.items, item, name)
|
table_replace(usage.items, item, name)
|
||||||
|
|
||||||
usages_cache[name] = usages_cache[name] or {}
|
usages_cache[name] = usages_cache[name] or {}
|
||||||
insert(usages_cache[name], 1, usage)
|
insert(usages_cache[name], 1, usage)
|
||||||
|
|
||||||
added[name] = true
|
added[name] = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -817,7 +814,16 @@ local function get_usages(recipe)
|
||||||
usages_cache[item] = usages_cache[item] or {}
|
usages_cache[item] = usages_cache[item] or {}
|
||||||
insert(usages_cache[item], 1, recipe)
|
insert(usages_cache[item], 1, recipe)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function get_usages(recipe)
|
||||||
|
local added = {}
|
||||||
|
|
||||||
|
for _, item in pairs(recipe.items) do
|
||||||
|
item = reg_aliases[item] or item
|
||||||
|
|
||||||
|
if not added[item] then
|
||||||
|
get_item_usages(item, recipe, added)
|
||||||
added[item] = true
|
added[item] = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Ŝarĝante…
Reference in New Issue