changeset 140:cd461a41723c

Now keeping track how many times an item has been queued into your favorite crafting addon.
author Zerotorescue
date Tue, 18 Jan 2011 11:34:48 +0100
parents e336a94359d8
children 5ed50feddeb0
files Core.lua Modules/Config.lua Modules/Queue.lua
diffstat 3 files changed, 17 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/Core.lua	Tue Jan 18 06:33:06 2011 +0100
+++ b/Core.lua	Tue Jan 18 11:34:48 2011 +0100
@@ -71,6 +71,8 @@
 				},
 			},
 			groups = {
+				-- items = {},
+				-- isVirtual = nil,
 			},
 		},
 		factionrealm = {
--- a/Modules/Config.lua	Tue Jan 18 06:33:06 2011 +0100
+++ b/Modules/Config.lua	Tue Jan 18 11:34:48 2011 +0100
@@ -95,7 +95,7 @@
 		return tostring( 7 - (itemRarity or 0) ) .. (itemName or "");
 	end,
 	get = function(info)
-		return tostring(info[#info]); -- Ace is going to be anal about this if it's a numeric value, so we transmute it into a string here then back to a number on the other side
+		return tostring(info[#info]); -- Ace is going to be bitching about this if it's a numeric value, so we transmute it into a string here then back to a number on the other side
 	end,
 	set = function(groupId, itemData)
     	-- This is NOT a real "set", we pass the widget reference to this function which contains similar, but not the same, info.
@@ -152,12 +152,12 @@
 		addon.db.profile.groups[groupName].items = {};
 	end
 	
-	-- Merge all items from all groups together
+	-- Merge all items from all groups together (we only use this to check if an item is already in a group)
 	local items = {};
 	for groupName, values in pairs(addon.db.profile.groups) do
 		if values.items then
-			for itemId, _ in pairs(values.items) do
-				items[itemId] = true;
+			for itemId, count in pairs(values.items) do
+				items[itemId] = tonumber(count) or 0;
 			end
 		end
 	end
@@ -2017,7 +2017,7 @@
 									
 									if temp.items then
 										-- Remove items that are already in another group
-										for value, _ in pairs(temp.items) do
+										for value, count in pairs(temp.items) do
 											local itemId = tonumber(value);
 											
 											local itemData = addon.ItemData:New(itemId);
@@ -2031,7 +2031,7 @@
 											else
 												-- Ensure the keys are numeric
 												temp.items[value] = nil;
-												temp.items[itemId] = true;
+												temp.items[itemId] = tonumber(count) or 0;
 											end
 										end
 									end
--- a/Modules/Queue.lua	Tue Jan 18 06:33:06 2011 +0100
+++ b/Modules/Queue.lua	Tue Jan 18 11:34:48 2011 +0100
@@ -33,6 +33,14 @@
 				
 				OnQueueCancel();
 				return;
+			else
+				-- Update the crafted-item count
+				for groupName, values in pairs(addon.db.profile.groups) do
+					if values.items and values.items[q.itemId] then
+						values.items[q.itemId] = tonumber(values.items[q.itemId]) + 1;
+						break;
+					end
+				end
 			end
 		else
 			addon:Debug("Lost %s", IdToItemLink(q.itemId));
@@ -273,7 +281,7 @@
 	local minCraftingQueue = floor( addon:GetOptionByKey(groupName, "minCraftingQueue") * restockTarget ); -- If the minCraftingQueue is 5% and restockTarget is 60, this will result in 3
 	local priceThreshold = addon:GetOptionByKey(groupName, "priceThreshold");
 	
-	for itemId in pairs(addon.db.profile.groups[groupName].items) do
+	for itemId, count in pairs(addon.db.profile.groups[groupName].items) do
 		if craftables[itemId] then
 			local currentStock = addon:GetItemCount(itemId, groupName);