From 8351d56f3b92dbb4d1bc26b9c9fe804f6219c9b4 Mon Sep 17 00:00:00 2001 From: Manuel Simon Hirsig Date: Sat, 5 Mar 2016 12:55:33 +0100 Subject: [PATCH] --amend --- info.lua | 32 +++++++++++++++++++++++--------- post_frame.lua | 4 ++-- search_frame.lua | 2 +- 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/info.lua b/info.lua index d5ac1e1..6fbd7d6 100644 --- a/info.lua +++ b/info.lua @@ -293,16 +293,30 @@ function public.tooltip(setter) end function private.item_charges(tooltip) - for _, line in ipairs(tooltip) do - -- recipes also contain the charges tooltip for the item they teach so we have to ignore them - local ignore_pattern = '^Use: Teaches you how to create' - if strfind(line.left_text or '', ignore_pattern) or strfind(line.right_text or '', ignore_pattern) then - return + local use_entry_count = 0 + for _, line in ipairs(tooltip) do + if strfind(line.left_text or '', ITEM_SPELL_TRIGGER_ONUSE) then + use_entry_count = use_entry_count + 1 end - local pattern = '^(%d+) Charges$' - local _, _, left_charges_string = strfind(line.left_text or '', pattern) - local _, _, right_charges_string = strfind(line.right_text or '', pattern) - local charges = tonumber(left_charges_string) or tonumber(right_charges_string) + if strfind(line.right_text or '', ITEM_SPELL_TRIGGER_ONUSE) then + use_entry_count = use_entry_count + 1 + end + end + if use_entry_count > 1 then -- it's presumably a recipe + return + end + + for _, line in ipairs(tooltip) do + local pattern1 = '^'..gsub(ITEM_SPELL_CHARGES, '%%d', '(%%d)')..'$' + local pattern2 = '^'..gsub(ITEM_SPELL_CHARGES_P1, '%%d', '(%%d)')..'$' + + local _, _, left_charges_string1 = strfind(line.left_text or '', pattern1) + local _, _, left_charges_string2 = strfind(line.left_text or '', pattern2) + + local _, _, right_charges_string1 = strfind(line.right_text or '', pattern1) + local _, _, right_charges_string2 = strfind(line.right_text or '', pattern2) + + local charges = tonumber(left_charges_string1) or tonumber(left_charges_string2) or tonumber(right_charges_string1) or tonumber(right_charges_string2) if charges then return charges end diff --git a/post_frame.lua b/post_frame.lua index 8ed277c..45dc141 100644 --- a/post_frame.lua +++ b/post_frame.lua @@ -724,8 +724,8 @@ end function private.auctionable(item_info) local durability, max_durability = Aux.info.durability(item_info.tooltip) return Aux.static.item_info(item_info.item_id) - and not Aux.info.tooltip_match('soulbound', item_info.tooltip) - and not Aux.info.tooltip_match('conjured item', item_info.tooltip) + and not Aux.info.tooltip_match(ITEM_SOULBOUND, item_info.tooltip) + and not Aux.info.tooltip_match(ITEM_CONJURED, item_info.tooltip) and not item_info.lootable and not (durability and durability < max_durability) end diff --git a/search_frame.lua b/search_frame.lua index 900fa3d..22419b4 100644 --- a/search_frame.lua +++ b/search_frame.lua @@ -455,7 +455,7 @@ function public.on_load() local function add_modifier(...) local current_filter_string = private.search_box:GetText() for i=1,arg.n do - if string.sub(current_filter_string, strlen(current_filter_string), strlen(current_filter_string)) ~= '/' then + if current_filter_string ~= '' and string.sub(current_filter_string, strlen(current_filter_string), strlen(current_filter_string)) ~= '/' then current_filter_string = current_filter_string..'/' end current_filter_string = current_filter_string..arg[i]