All pastes #81609 Raw Edit

Kirov

public lua v1 · immutable
·published 2006-07-07 17:56 UTC
rendered paste body
function cgCrafty:BuildListByReagent(searchText, craft)	local foundIndex = 0	self.found = {}		local num, i, skillName, skillType, numAvailable, isExpanded = (craft and GetNumCrafts() or GetNumTradeSkills()), 1;	while i <= num do		if ( craft ) then			skillName, _, skillType, numAvailable, isExpanded = GetCraftInfo(i)		else			skillName, skillType, numAvailable, isExpanded = GetTradeSkillInfo(i)		end				if ( skillType ~= "header" ) then			for e=1, (craft and GetCraftNumReagents(i) or GetTradeSkillNumReagents(i)), 1 do				local reagentName								if ( craft ) then					reagentName, _, _, _ = GetCraftReagentInfo(i, e)				else					reagentName, _, _, _ = GetTradeSkillReagentInfo(i, e)				end								if ( reagentName and strfind(string.lower(reagentName), string.lower(searchText)) ) then					foundIndex = foundIndex + 1					self.found[foundIndex] = {						name			= skillName,						type 			= skillType,						available		= numAvailable,						index 			= i					}					end			end		elseif ( skillType == "header" and not isExpanded ) then			-- We need to expand any unexpanded header types, otherwise we can't parse their sub data.			ExpandTradeSkillSubClass(i)			num = (craft and GetNumCrafts() or GetNumTradeSkills());		end		i = i + 1;	endend