Quantcast

Skip lines that only sometimes appear, plus blank lines at the end

Kevin Lyles [07-25-10 - 01:04]
Skip lines that only sometimes appear, plus blank lines at the end

Allows for more consistent data and easier comparisons
Filename
ItemScanner.lua
diff --git a/ItemScanner.lua b/ItemScanner.lua
index 6fd400f..4881580 100644
--- a/ItemScanner.lua
+++ b/ItemScanner.lua
@@ -14,6 +14,14 @@ local patterns = {
 	"^Technique:",
 }

+local skippedLines = {
+	"^Already known$",
+	"^Prospectable$",
+	"^Disenchanting requires Enchanting %(%d+%)$",
+	"^Cannot be disenchanted",
+	"^Collected %(%d/%d%)$",
+}
+
 local function scanItemLink(link)
 	local textL, textR

@@ -80,11 +88,24 @@ local function scanItemLink(link)
 		helpful = IsHelpfulItem(link),
 		harmful = IsHarmfulItem(link),
 	}
+	local numSkipped = 0
 	for i = 1, ItemScannerHiddenTooltip:NumLines() do
-		IS_item_info[link][i] = {
-			left = _G["ItemScannerHiddenTooltipTextLeft" .. i]:GetText(),
-			right = _G["ItemScannerHiddenTooltipTextRight" .. i]:GetText(),
-		}
+		textL = _G["ItemScannerHiddenTooltipTextLeft" .. i]:GetText()
+		textR = _G["ItemScannerHiddenTooltipTextRight" .. i]:GetText()
+		local skip = false
+		for _, pattern in ipairs(skippedLines) do
+			if textL:find(pattern) then
+				skip = true
+				numSkipped = numSkipped + 1
+				break
+			end
+		end
+		if not skip and (i ~= ItemScannerHiddenTooltip:NumLines() or (textL ~= " " and textL ~= "" and textR ~= " " and textR ~= "")) then
+			IS_item_info[link][i - numSkipped] = {
+				left = textL,
+				right = textR,
+			}
+		end
 	end

 	return true