crafting: fixed lookup for unknown items without description

This commit is contained in:
Alexander Weber 2017-03-21 21:33:32 +01:00
parent 6185fa7853
commit 79e0a1e225
2 changed files with 26 additions and 24 deletions

View File

@ -121,31 +121,33 @@ local function update_crafting_preview(state)
group_list:clearItems()
local out_list = {}
for group1, groupdef1 in pairs(cache.citems[itemdef.name].cgroups) do
if not string.find(group1, "ingredient:") then
out_list[group1] = groupdef1
for group2, groupdef2 in pairs(out_list) do
if string.len(group1) > string.len(group2) and
string.sub(group1,1,string.len(group2)) == group2 then
-- group2 is top-group of group1. Remove the group2
out_list[group2] = nil
elseif string.len(group1) < string.len(group2) and
string.sub(group2,1,string.len(group1)) == group1 then
-- group2 is top-group of group1. Remove the group2
out_list[group1] = nil
if cache.citems[itemdef.name] then
for group1, groupdef1 in pairs(cache.citems[itemdef.name].cgroups) do
if not string.find(group1, "ingredient:") then
out_list[group1] = groupdef1
for group2, groupdef2 in pairs(out_list) do
if string.len(group1) > string.len(group2) and
string.sub(group1,1,string.len(group2)) == group2 then
-- group2 is top-group of group1. Remove the group2
out_list[group2] = nil
elseif string.len(group1) < string.len(group2) and
string.sub(group2,1,string.len(group1)) == group1 then
-- group2 is top-group of group1. Remove the group2
out_list[group1] = nil
end
end
end
end
end
local out_list_sorted = {}
for group, groupdef in pairs(out_list) do
table.insert(out_list_sorted, groupdef)
end
table.sort(out_list_sorted, function(a,b)
return a.group_desc < b.group_desc
end)
for _, groupdef in ipairs(out_list_sorted) do
group_list:addItem(groupdef.group_desc)
local out_list_sorted = {}
for group, groupdef in pairs(out_list) do
table.insert(out_list_sorted, groupdef)
end
table.sort(out_list_sorted, function(a,b)
return a.group_desc < b.group_desc
end)
for _, groupdef in ipairs(out_list_sorted) do
group_list:addItem(groupdef.group_desc)
end
end
else
inf_state:get("info1"):setText("")

View File

@ -18,7 +18,7 @@ function doc_addon.is_revealed_item(itemname, playername)
elseif itemdef.type == "craft" then
category_id = "craftitems"
end
if category_id then
if category_id and doc.entry_exists(category_id, itemname) then
return doc.entry_revealed(playername, category_id, itemname)
else
-- unknown item
@ -43,7 +43,7 @@ function doc_addon.show(itemname, playername)
category_id = "craftitems"
end
end
if category_id then
if category_id and doc.entry_exists(category_id, itemname) then
doc.show_entry(playername, category_id, itemname, true)
end
end