Quantcast

Reordered parameters on queue item generation functions.

pschifferer [01-23-09 - 00:51]
Reordered parameters on queue item generation functions.
Filename
Cauldron/CauldronQueue.lua
diff --git a/Cauldron/CauldronQueue.lua b/Cauldron/CauldronQueue.lua
index ec01e06..6391e2f 100644
--- a/Cauldron/CauldronQueue.lua
+++ b/Cauldron/CauldronQueue.lua
@@ -11,7 +11,8 @@ CauldronQueue = {};
 		["name"] = "<name of skill>",
 		["icon"] = "<icon path>",
 		["tradeskill"] = "<name of tradeskill>",
-		["index"] = <index of skill>,
+		["skillIndex"] = <index of skill>,
+		["reagentIndex"] = <index of reagent>, -- for intermediates
 		["amount"] = <amount>,
 		["priority"] = <priority>,
 	};
@@ -23,6 +24,8 @@ CauldronQueue = {};
 		["icon"] = "<icon path>",
 		["amount"] = <amount>,
 		["tradeskill"] = "<tradeskill that caused this reagent to be listed>",
+		["skillIndex"] = <index of skill>,
+		["reagentIndex"] = <index of reagent>, -- for intermediates
 	};
 --]]

@@ -36,13 +39,14 @@ function CauldronQueue:NewQueue()
 	return queue;
 end

-function CauldronQueue:NewItem(name, icon, tradeskill, index, amount, priority)
+function CauldronQueue:NewItem(name, icon, amount, priority, tradeskill, skillIndex, reagentIndex)

 	local queueItem = {
 		["name"] = name or "",
 		["icon"] = icon or "",
 		["tradeskill"] = tradeskill or "",
-		["index"] = index,
+		["skillIndex"] = skillIndex,
+		["reagentIndex"] = reagentIndex,
 		["amount"] = amount or 1,
 		["priority"] = priority or 0,
 	};
@@ -50,7 +54,7 @@ function CauldronQueue:NewItem(name, icon, tradeskill, index, amount, priority)
 	return queueItem;
 end

-function CauldronQueue:NewReagent(name, icon, amount, tradeskill, index, skillIndex)
+function CauldronQueue:NewReagent(name, icon, amount, tradeskill, skillIndex, reagentIndex)

 	local reagent = {
 		["name"] = name or "",
@@ -58,7 +62,7 @@ function CauldronQueue:NewReagent(name, icon, amount, tradeskill, index, skillIn
 		["amount"] = amount or 1,
 		["tradeskill"] = tradeskill,
 		["skillIndex"] = skillIndex,
-		["index"] = index,
+		["reagentIndex"] = reagentIndex,
 	};

 	return reagent;
@@ -154,7 +158,7 @@ function CauldronQueue:AddItem(queue, skillInfo, amount, suppressCalc)
 		item.amount = item.amount + amount;
 	else
 		-- it's not there, so create a new instance
-		queue.main[skillInfo.name] = CauldronQueue:NewItem(skillInfo.name, skillInfo.icon, skillInfo.tradeskill, skillInfo.index, amount);
+		queue.main[skillInfo.name] = CauldronQueue:NewItem(skillInfo.name, skillInfo.icon, amount, 0, skillInfo.tradeskill, skillInfo.index);
 	end

 	if not suppressCalc then
@@ -270,7 +274,7 @@ function CauldronQueue:AddIntermediate(queue, reagent, amount)
 		local skillInfo = Cauldron:GetSkillInfoForItem(reagent.name);

 		-- it's not there, so create a new instance
-		queue.intermediate[reagent.name] = CauldronQueue:NewItem(reagent.name, reagent.icon, skillInfo.tradeskill, skillInfo.index, amount);
+		queue.intermediate[reagent.name] = CauldronQueue:NewItem(reagent.name, reagent.icon, amount, 0, skillInfo.tradeskill, skillInfo.index, reagent.index);
 	end

 end
@@ -296,7 +300,7 @@ function CauldronQueue:AddReagent(queue, reagent, amount, tradeskill)
 		item.amount = (tonumber(item.amount) or 0) + amount;
 	else
 		-- it's not there, so create a new instance
-		queue.reagents[reagent.name] = CauldronQueue:NewReagent(reagent.name, reagent.icon, amount, tradeskill, reagent.index, reagent.skillIndex);
+		queue.reagents[reagent.name] = CauldronQueue:NewReagent(reagent.name, reagent.icon, amount, tradeskill, reagent.skillIndex, reagent.index);
 	end

 end