diff data.lua @ 26:886be292feec

Avoid scanning when tradeskill is not fully loaded (no recipe or the first one is not a header)
author contrebasse
date Thu, 28 Apr 2011 19:43:07 +0200
parents 4ea38bae4174
children fd76c8951b7d
line wrap: on
line diff
--- a/data.lua	Thu Apr 28 19:31:01 2011 +0200
+++ b/data.lua	Thu Apr 28 19:43:07 2011 +0200
@@ -257,7 +257,14 @@
 
 	-- the function who scans the tradeskill
 	function A:ScanSimpleRecipes()
-		for i = 1,GetNumTradeSkills() do
+		-- Check if the tradeskill is loaded
+		-- Has to have recipes and begin with a header
+		local NRecipes = GetNumTradeSkills()
+		if NRecipes==0 or select(2,GetTradeSkillInfo(1))~="header" then
+			return
+		end
+	
+		for i = 2,NRecipes do -- The first one is a header
 			local skillName, skillType, numAvailable, isExpanded, serviceType, numSkillUps = GetTradeSkillInfo(i)
 			if skillType ~= "header" then
 				if GetTradeSkillNumReagents(i) == 1 then
@@ -303,5 +310,8 @@
 				end -- if
 			end -- if
 		end -- for
+		
+		-- the scanning is complete
+		return true
 	end -- function
 end -- do