comparison Queue.lua @ 61:d903b0a151d3

Command handler function is now private, no need to keep it global when you can use the global SlashCmdList["INVENTORIUM"](msg) instead. Added database updating mechanism. All database vars are now stored in profiles rather than global. Now refreshing options when a different profile is selected. Fixed an issue with minimum local and global stock values not being inherited from the defaults.
author Zerotorescue
date Wed, 22 Dec 2010 15:04:09 +0100
parents 58fb38f0b447
children fee06221176f
comparison
equal deleted inserted replaced
60:12c2b20ca843 61:d903b0a151d3
21 21
22 function mod:QueueAll() 22 function mod:QueueAll()
23 local playerName = UnitName("player"); 23 local playerName = UnitName("player");
24 24
25 -- Go through all groups 25 -- Go through all groups
26 for groupName, values in pairs(addon.db.global.groups) do 26 for groupName, values in pairs(addon.db.profile.groups) do
27 local trackAt = (values.trackAtCharacters or (values.trackAtCharacters == nil and addon.db.global.defaults.trackAtCharacters)); 27 local trackAt = (values.trackAtCharacters or (values.trackAtCharacters == nil and addon.db.profile.defaults.trackAtCharacters));
28 28
29 if trackAt[playerName] then 29 if trackAt[playerName] then
30 self:QueueGroup(groupName); 30 self:QueueGroup(groupName);
31 end 31 end
32 end 32 end
33 end 33 end
34 34
35 function mod:QueueGroup(groupName) 35 function mod:QueueGroup(groupName)
36 if not addon.db.global.groups[groupName] then 36 if not addon.db.profile.groups[groupName] then
37 print(("Tried to queue items from a group named \"%s\", but no such group exists."):format(groupName)); 37 print(("Tried to queue items from a group named \"%s\", but no such group exists."):format(groupName));
38 return; 38 return;
39 end 39 end
40 40
41 local temp = {}; 41 local temp = {};
44 for i = 1, GetNumTradeSkills() do 44 for i = 1, GetNumTradeSkills() do
45 -- Process every single tradeskill 45 -- Process every single tradeskill
46 self:ProcessTradeSkill(i, groupName, temp); 46 self:ProcessTradeSkill(i, groupName, temp);
47 end 47 end
48 48
49 if addon.db.global.groups[groupName].items then 49 if addon.db.profile.groups[groupName].items then
50 for itemId, _ in pairs(addon.db.global.groups[groupName].items) do 50 for itemId, _ in pairs(addon.db.profile.groups[groupName].items) do
51 if not temp[itemId] then 51 if not temp[itemId] then
52 local itemLink = select(2, GetItemInfo(itemId)); 52 local itemLink = select(2, GetItemInfo(itemId));
53 53
54 print("Couldn't queue " .. itemLink .. " (not part of this profession)"); 54 print("Couldn't queue " .. itemLink .. " (not part of this profession)");
55 end 55 end
68 itemId = tonumber(itemLink:match("|Henchant:([-0-9]+)|h")); 68 itemId = tonumber(itemLink:match("|Henchant:([-0-9]+)|h"));
69 69
70 itemId = addon.scrollIds[itemId]; -- change enchantIds into scrollIds 70 itemId = addon.scrollIds[itemId]; -- change enchantIds into scrollIds
71 end 71 end
72 72
73 if addon.db.global.groups[groupName].items[itemId] then 73 if addon.db.profile.groups[groupName].items[itemId] then
74 -- This item is in this group, queue it! 74 -- This item is in this group, queue it!
75 75
76 if temp then 76 if temp then
77 -- Remember which items have been processed 77 -- Remember which items have been processed
78 temp[itemId] = true; 78 temp[itemId] = true;