comparison Modules/Crafting.lua @ 68:2d65db19d3ce

Fixed a bug with the crafting threshold options. Updated /ia queue so that it is a shortcut to using /ia crafting and then clicking export.
author Asa Ayers <Asa.Ayers@Gmail.com>
date Wed, 28 Jul 2010 11:37:43 -0700
parents b6c30a5156f9
children 3930518cb8d9
comparison
equal deleted inserted replaced
67:b6c30a5156f9 68:2d65db19d3ce
7 local validateMoney = ItemAuditor.validateMoney 7 local validateMoney = ItemAuditor.validateMoney
8 local parseMoney = ItemAuditor.parseMoney 8 local parseMoney = ItemAuditor.parseMoney
9 9
10 local realData = {} 10 local realData = {}
11 11
12
13 local queueDestinations = {}
14
15 function Crafting.RegisterQueueDestination(name, destination)
16 queueDestinations[name] = destination
17 end
12 18
13 -- TODO: Convert this to a text field. 19 -- TODO: Convert this to a text field.
14 local craftingThresholds = {5000, 10000, 50000} 20 local craftingThresholds = {5000, 10000, 50000}
15 local craftingThresholdsDisplay = {} 21 local craftingThresholdsDisplay = {}
16 22
17 for key, value in pairs(craftingThresholds) do 23 for key, value in pairs(craftingThresholds) do
18 craftingThresholdsDisplay[key] = ItemAuditor:FormatMoney(value, '', true) 24 craftingThresholdsDisplay[key] = ItemAuditor:FormatMoney(value, '', true)
19 -- craftingThresholdsDisplay[key] = value 25 -- craftingThresholdsDisplay[key] = value
26 end
27
28 function ItemAuditor:GetCraftingThreshold()
29 local key = ItemAuditor.db.char.crafting_threshold
30 return craftingThresholds[key]
20 end 31 end
21 32
22 ItemAuditor.Options.args.crafting_options = { 33 ItemAuditor.Options.args.crafting_options = {
23 name = "Crafting with Skillet", 34 name = "Crafting with Skillet",
24 desc = "/ia queue", 35 desc = "/ia queue",
73 { name= "Total Profit", width = 100, align = "RIGHT", 84 { name= "Total Profit", width = 100, align = "RIGHT",
74 ['DoCellUpdate'] = displayMoney, 85 ['DoCellUpdate'] = displayMoney,
75 }, 86 },
76 } 87 }
77 88
78 local function ExportToSkillet() 89 function Crafting.ExportToSkillet(data)
90 local skillString = select(3, string.find(data.recipeLink, "^|%x+|H(.+)|h%[.+%]"))
91 local _, skillId = strsplit(":", skillString)
92
93 ItemAuditor:AddToQueue(skillId,tradeSkillIndex, data.queue)
94 end
95
96 Crafting.RegisterQueueDestination('Skillet', Crafting.ExportToSkillet)
97
98
99
100 function Crafting.Export(destination)
101 if type(destination) == 'function' then
102 -- do nothing
103 elseif destination == nil then
104 destination = queueDestinations['Skillet']
105 elseif type(destination) == 'string' then
106 destination = queueDestinations[destination]
107 else
108 error('destination must be a function or a string')
109 end
110
79 local index = 1 111 local index = 1
80 local data = ItemAuditor:GetCraftingRow(index) 112 local data = ItemAuditor:GetCraftingRow(index)
81 while data do 113 while data do
82 local skillString = select(3, string.find(data.recipeLink, "^|%x+|H(.+)|h%[.+%]")) 114 if data.queue > 0 then
83 local _, skillId = strsplit(":", skillString) 115 destination(data)
84 116 end
85 ItemAuditor:AddToQueue(skillId,tradeSkillIndex, data.queue)
86 index = index + 1 117 index = index + 1
87 data = ItemAuditor:GetCraftingRow(index) 118 data = ItemAuditor:GetCraftingRow(index)
88 119
89 end 120 end
90 end 121 end
316 realData[row] = data 347 realData[row] = data
317 row = row + 1 348 row = row + 1
318 end 349 end
319 end 350 end
320 table.sort(realData, function(a, b) return a.profit*a.queue > b.profit*b.queue end) 351 table.sort(realData, function(a, b) return a.profit*a.queue > b.profit*b.queue end)
321 craftingTable:SetFilter(tableFilter) 352 if craftingTable then
322 self:RefreshCraftingTable() 353 craftingTable:SetFilter(tableFilter)
354 self:RefreshCraftingTable()
355 end
323 end 356 end
324 357
325 function ItemAuditor:RefreshCraftingTable() 358 function ItemAuditor:RefreshCraftingTable()
326 for key, data in pairs(realData) do 359 for key, data in pairs(realData) do
327 tableData[key] = { 360 tableData[key] = {