annotate Modules/Crafting.lua @ 99:e9b903cf9b33

Added a menu to allow the user to see what is to be crafted, only what you hae mats for, or view everything so you can see why something isn't to be crafted.
author Asa Ayers <Asa.Ayers@Gmail.com>
date Thu, 19 Aug 2010 23:14:30 -0700
parents 63823b6b5e28
children 53147a647e28
rev   line source
Asa@63 1 local ItemAuditor = select(2, ...)
Asa@63 2 local Crafting = ItemAuditor:NewModule("Crafting")
Asa@59 3
Asa@86 4 local Utils = ItemAuditor:GetModule("Utils")
Asa@86 5
Asa@59 6 local AceGUI = LibStub("AceGUI-3.0")
Asa@59 7 local ScrollingTable = LibStub("ScrollingTable")
Asa@59 8
Asa@59 9 local validateMoney = ItemAuditor.validateMoney
Asa@59 10 local parseMoney = ItemAuditor.parseMoney
Asa@59 11
Asa@59 12 local realData = {}
Asa@59 13
Asa@67 14
Asa@68 15 local queueDestinations = {}
Asa@70 16 local displayCraftingDestinations = {}
Asa@68 17 function Crafting.RegisterQueueDestination(name, destination)
Asa@68 18 queueDestinations[name] = destination
Asa@70 19 displayCraftingDestinations[name] = name
Asa@70 20 end
Asa@70 21
Asa@70 22 function Crafting.UnRegisterQueueDestination(name)
Asa@70 23 queueDestinations[name] = nil
Asa@70 24 displayCraftingDestinations[name] = nil
Asa@70 25 end
Asa@70 26
Asa@70 27 function Crafting.GetQueueDestination()
Asa@70 28 local dest = ItemAuditor.db.profile.queue_destination
Asa@70 29 if dest and queueDestinations[dest] then
Asa@70 30 return queueDestinations[dest], dest
Asa@70 31 end
Asa@70 32 -- If there is none selected or the selected option has
Asa@70 33 -- dissapeared, choose the first one in the list
Asa@70 34 for name, func in pairs(queueDestinations) do
Asa@70 35 if dest then
Asa@70 36 ItemAuditor:Print("%s is no longer available as a queue destination. %s is the new default", dest, name)
Asa@70 37 end
Asa@70 38 ItemAuditor.db.profile.queue_destination = name
Asa@70 39 return func, name
Asa@70 40 end
Asa@70 41
Asa@70 42 error('Unable to determine queue destination.')
Asa@68 43 end
Asa@68 44
Asa@67 45 -- TODO: Convert this to a text field.
Asa@67 46 local craftingThresholds = {5000, 10000, 50000}
Asa@67 47 local craftingThresholdsDisplay = {}
Asa@67 48
Asa@67 49 for key, value in pairs(craftingThresholds) do
Asa@67 50 craftingThresholdsDisplay[key] = ItemAuditor:FormatMoney(value, '', true)
Asa@67 51 -- craftingThresholdsDisplay[key] = value
Asa@67 52 end
Asa@67 53
Asa@68 54 function ItemAuditor:GetCraftingThreshold()
Asa@68 55 local key = ItemAuditor.db.char.crafting_threshold
Asa@68 56 return craftingThresholds[key]
Asa@68 57 end
Asa@68 58
Asa@67 59 ItemAuditor.Options.args.crafting_options = {
Asa@70 60 name = "Crafting",
Asa@67 61 type = 'group',
Asa@67 62 args = {
Asa@67 63 crafting_threshold = {
Asa@67 64 type = "select",
Asa@67 65 name = "Crafting Threshold",
Asa@67 66 desc = "Don't create items that will make less than this amount of profit",
Asa@67 67 values = craftingThresholdsDisplay,
Asa@67 68 get = function() return ItemAuditor.db.char.crafting_threshold end,
Asa@67 69 set = function(info, value) ItemAuditor.db.char.crafting_threshold = value end,
Asa@72 70 order = 0,
Asa@67 71 },
Asa@70 72 queue_destination = {
Asa@70 73 type = "select",
Asa@70 74 name = "Queue Destination",
Asa@70 75 desc = "Select the addon who's queue you would like ItemAuditor to post to.",
Asa@70 76 values = displayCraftingDestinations,
Asa@70 77 get = function() return select(2, Crafting.GetQueueDestination()) end,
Asa@70 78 set = function(info, value) ItemAuditor.db.profile.queue_destination = value end,
Asa@72 79 order = 1,
Asa@70 80 },
Asa@72 81 deciders = {
Asa@72 82 type="header",
Asa@72 83 name="Crafting Deciders",
Asa@72 84 order = 10,
Asa@72 85 },
Asa@72 86
Asa@67 87 },
Asa@67 88 }
Asa@67 89
Asa@59 90 local function displayMoney(rowFrame, cellFrame, data, cols, row, realrow, column, fShow, table, ...)
Asa@59 91 if fShow == true then
Asa@59 92 local money = data[realrow][column]
Asa@59 93 if money then
Asa@59 94 cellFrame.text:SetText(ItemAuditor:FormatMoney(tonumber(money)))
Asa@59 95 else
Asa@59 96 cellFrame.text:SetText("")
Asa@59 97 end
Asa@59 98
Asa@59 99 end
Asa@59 100 end
Asa@59 101
Asa@59 102 local craftingCols = {
Asa@59 103 { name= "Item", width = 200, defaultsort = "desc",
Asa@59 104 ['DoCellUpdate'] = function(rowFrame, cellFrame, data, cols, row, realrow, column, fShow, table, ...)
Asa@59 105 if fShow == true then
Asa@59 106 local data = realData[realrow]
Asa@59 107 cellFrame.text:SetText(data.link)
Asa@59 108 end
Asa@59 109 end,
Asa@59 110 },
Asa@59 111 { name= "Cost Each", width = 100, align = "RIGHT",
Asa@59 112 ['DoCellUpdate'] = displayMoney,
Asa@59 113 },
Asa@59 114 { name= "Est Sale Each", width = 100, align = "RIGHT",
Asa@59 115 ['DoCellUpdate'] = displayMoney,
Asa@59 116 },
Asa@99 117 { name= "Decided By", width = 125, align = "RIGHT",
Asa@59 118
Asa@59 119 },
Asa@59 120 { name= "craft", width = 50, align = "RIGHT",
Asa@59 121
Asa@59 122 },
Asa@99 123 { name= "Have Mats", width = 60, align = "RIGHT",
Asa@99 124
Asa@99 125 },
Asa@59 126 { name= "Total Profit", width = 100, align = "RIGHT",
Asa@59 127 ['DoCellUpdate'] = displayMoney,
Asa@59 128 },
Asa@59 129 }
Asa@59 130
Asa@68 131 function Crafting.ExportToSkillet(data)
Asa@68 132 local skillString = select(3, string.find(data.recipeLink, "^|%x+|H(.+)|h%[.+%]"))
Asa@68 133 local _, skillId = strsplit(":", skillString)
Asa@68 134
Asa@68 135 ItemAuditor:AddToQueue(skillId,tradeSkillIndex, data.queue)
Asa@68 136 end
Asa@68 137
Asa@68 138 Crafting.RegisterQueueDestination('Skillet', Crafting.ExportToSkillet)
Asa@68 139
Asa@68 140
Asa@68 141
Asa@68 142 function Crafting.Export(destination)
Asa@68 143 if type(destination) == 'function' then
Asa@68 144 -- do nothing
Asa@68 145 elseif destination == nil then
Asa@70 146 destination = Crafting.GetQueueDestination()
Asa@68 147 elseif type(destination) == 'string' then
Asa@68 148 destination = queueDestinations[destination]
Asa@68 149 else
Asa@68 150 error('destination must be a function or a string')
Asa@68 151 end
Asa@68 152
Asa@59 153 local index = 1
Asa@59 154 local data = ItemAuditor:GetCraftingRow(index)
Asa@59 155 while data do
Asa@68 156 if data.queue > 0 then
Asa@68 157 destination(data)
Asa@68 158 end
Asa@61 159 index = index + 1
Asa@61 160 data = ItemAuditor:GetCraftingRow(index)
Asa@59 161
Asa@59 162 end
Asa@59 163 end
Asa@59 164
Asa@74 165 -- ItemAuditor:GetModule('Crafting').filter_queued = false
Asa@99 166 Crafting.filter_have_mats = false
Asa@99 167 Crafting.filter_show_all = false
Asa@74 168 local function tableFilter(self, row, ...)
Asa@99 169 if Crafting.filter_show_all then
Asa@99 170 return true
Asa@99 171 end
Asa@99 172
Asa@74 173 -- column 5 is how many should be crafted
Asa@99 174 if Crafting.filter_have_mats and row[6] == 'n' then
Asa@99 175 return false
Asa@99 176 end
Asa@99 177 if strfind(row[4], 'VETO: .*') or row[5] == 0 then
Asa@74 178 return false
Asa@74 179 end
Asa@74 180 return true
Asa@74 181 end
Asa@74 182
Asa@59 183 local craftingContent = false
Asa@59 184 local craftingTable = false
Asa@60 185 local btnProcess = false
Asa@59 186 local function ShowCrafting(container)
Asa@59 187 if craftingContent == false then
Asa@59 188 local window = container.frame
Asa@59 189 craftingContent = CreateFrame("Frame",nil,window)
Asa@59 190 craftingContent:SetBackdropColor(0, 0, 1, 0.5)
Asa@59 191 craftingContent:SetBackdropBorderColor(1, 0, 0, 1)
Asa@59 192
Asa@59 193 craftingContent:SetPoint("TOPLEFT", window, 10, -50)
Asa@59 194 craftingContent:SetPoint("BOTTOMRIGHT",window, -10, 10)
Asa@59 195
Asa@59 196 craftingTable = ScrollingTable:CreateST(craftingCols, 22, nil, nil, craftingContent )
Asa@59 197
Asa@59 198 IAcc = craftingContent
Asa@59 199 IAccWindow = window
Asa@59 200 craftingTable.frame:SetPoint("TOPLEFT",craftingContent, 0,0)
Asa@59 201 craftingTable.frame:SetPoint("BOTTOMRIGHT", craftingContent, 0, 30)
Asa@59 202
Asa@59 203 craftingTable:RegisterEvents({
Asa@59 204 ["OnEnter"] = function (rowFrame, cellFrame, data, cols, row, realrow, column, scrollingTable, ...)
Asa@59 205 if realrow then
Asa@59 206 local data = realData[realrow]
Asa@59 207
Asa@59 208 GameTooltip:SetOwner(rowFrame, "ANCHOR_CURSOR")
Asa@59 209 GameTooltip:SetHyperlink(data.link)
Asa@59 210 GameTooltip:Show()
Asa@59 211 end
Asa@59 212 end,
Asa@59 213 ["OnLeave"] = function (rowFrame, cellFrame, data, cols, row, realrow, column, scrollingTable, ...)
Asa@59 214 GameTooltip:Hide()
Asa@59 215 end,
Asa@59 216 });
Asa@59 217
Asa@99 218 local craftingView = CreateFrame("Button", nil, craftingContent, "UIPanelButtonTemplate")
Asa@99 219 craftingView:SetText("View")
Asa@99 220 craftingView:SetSize(50, 25)
Asa@99 221 craftingView:SetPoint("BOTTOMLEFT", craftingContent, 0, 0)
Asa@99 222
Asa@99 223 local menu = {
Asa@99 224 { text = "View", isTitle = true},
Asa@99 225 { text = "To be crafted", func = function()
Asa@99 226 Crafting.filter_have_mats = false
Asa@99 227 Crafting.filter_show_all = false
Asa@99 228 ItemAuditor:RefreshCraftingTable()
Asa@99 229 end },
Asa@99 230 { text = "Have Mats", func = function()
Asa@99 231 Crafting.filter_have_mats = true
Asa@99 232 Crafting.filter_show_all = false
Asa@99 233 ItemAuditor:RefreshCraftingTable()
Asa@99 234 end },
Asa@99 235 { text = "All", func = function()
Asa@99 236 Crafting.filter_have_mats = false
Asa@99 237 Crafting.filter_show_all = true
Asa@99 238 ItemAuditor:RefreshCraftingTable()
Asa@99 239 end },
Asa@99 240 }
Asa@99 241 local menuFrame = CreateFrame("Frame", "ExampleMenuFrame", UIParent, "UIDropDownMenuTemplate")
Asa@99 242 craftingView:SetScript("OnClick", function (self, button, down)
Asa@99 243 EasyMenu(menu, menuFrame, "cursor", 0 , 0, "MENU");
Asa@99 244 end)
Asa@99 245
Asa@99 246
Asa@59 247 btnProcess = CreateFrame("Button", nil, craftingContent, "UIPanelButtonTemplate")
Asa@59 248 btnProcess:SetText("Process")
Asa@59 249 btnProcess:SetSize(100, 25)
Asa@59 250 btnProcess:SetPoint("BOTTOMRIGHT", craftingContent, 0, 0)
Asa@59 251 btnProcess:RegisterForClicks("LeftButtonUp");
Asa@59 252
Asa@60 253 local function UpdateProcessTooltip(btn)
Asa@59 254 local data = ItemAuditor:GetCraftingRow(1)
Asa@59 255 if data then
Asa@59 256 GameTooltip:SetOwner(this, "ANCHOR_CURSOR")
Asa@59 257 GameTooltip:SetText(format('Create %sx%s', data.link, data.queue))
Asa@59 258 GameTooltip:Show()
Asa@59 259 end
Asa@60 260 end
Asa@60 261 btnProcess:SetScript("OnClick", function (self, button, down)
Asa@60 262 local data = ItemAuditor:GetCraftingRow(1)
Asa@60 263 if data then
Asa@60 264 ItemAuditor:Print('Crafting %sx%s', data.link, data.queue)
Asa@60 265 DoTradeSkill(data.tradeSkillIndex, data.queue)
Asa@60 266 data.queue = 0
Asa@60 267 ItemAuditor:RefreshCraftingTable()
Asa@60 268 UpdateProcessTooltip()
Asa@60 269 end
Asa@59 270 end)
Asa@59 271
Asa@60 272 btnProcess:SetScript("OnEnter", UpdateProcessTooltip)
Asa@60 273
Asa@59 274 btnProcess:SetScript("OnLeave", function()
Asa@59 275 GameTooltip:Hide()
Asa@59 276 end)
Asa@59 277
Asa@59 278 btnSkillet = CreateFrame("Button", nil, craftingContent, "UIPanelButtonTemplate")
Asa@99 279
Asa@59 280 btnSkillet:SetSize(125, 25)
Asa@59 281 btnSkillet:SetPoint("BOTTOMRIGHT", btnProcess, 'BOTTOMLEFT', 0, 0)
Asa@59 282 btnSkillet:RegisterForClicks("LeftButtonUp");
Asa@59 283 btnSkillet:SetScript("OnClick", function (self, button, down)
Asa@70 284 Crafting.Export()
Asa@59 285 end)
Asa@59 286
Asa@59 287 end
Asa@70 288 local destination = select(2, Crafting.GetQueueDestination())
Asa@70 289 btnSkillet:SetText("Export to "..destination)
Asa@70 290
Asa@59 291 craftingContent:Show()
Asa@59 292
Asa@59 293 if container.parent then
Asa@59 294 local width = 80
Asa@59 295 for i, data in pairs(craftingCols) do
Asa@59 296 width = width + data.width
Asa@59 297 end
Asa@59 298 container.parent:SetWidth(width);
Asa@59 299 end
Asa@59 300
Asa@59 301 ItemAuditor:RegisterEvent("TRADE_SKILL_SHOW", function()
Asa@59 302 if craftingContent and craftingContent:IsVisible() then
Asa@59 303 ItemAuditor:UpdateCraftingTable()
Asa@59 304 end
Asa@59 305 end)
Asa@59 306 ItemAuditor:UpdateCraftingTable()
Asa@59 307
Asa@59 308 return craftingContent
Asa@59 309 end
Asa@59 310
Asa@59 311
Asa@59 312
Asa@59 313 ItemAuditor:RegisterTab('Crafting', 'tab_crafting', ShowCrafting)
Asa@59 314 function ItemAuditor:DisplayCrafting()
Asa@59 315 self:CreateFrame('tab_crafting')
Asa@59 316 end
Asa@59 317
Asa@59 318 local craftingDeciders = {}
Asa@59 319
Asa@72 320 function Crafting.RegisterCraftingDecider(name, decider, options)
Asa@59 321 craftingDeciders[name] = decider
Asa@72 322
Asa@72 323 ItemAuditor.Options.args.crafting_options.args['chk'..name] = {
Asa@72 324 type = "toggle",
Asa@72 325 name = "Enable "..name,
Asa@72 326 get = function() return not ItemAuditor.db.profile.disabled_deciders[name] end,
Asa@72 327 set = function(info, value) ItemAuditor.db.profile.disabled_deciders[name] = not value end,
Asa@72 328 order = 11,
Asa@72 329 }
Asa@72 330
Asa@72 331 if options then
Asa@72 332 ItemAuditor.Options.args.crafting_options.args['decider_'..name] = {
Asa@72 333 handler = {},
Asa@72 334 name = name,
Asa@72 335 type = 'group',
Asa@72 336 args = options,
Asa@72 337 }
Asa@72 338 end
Asa@59 339 end
Asa@59 340
Asa@59 341 local lastWinnder = ""
Asa@59 342 local function Decide(data)
Asa@59 343 local newDecision = 0
Asa@74 344 local reason = ""
Asa@59 345 for name, decider in pairs(craftingDeciders) do
Asa@72 346 if not ItemAuditor.db.profile.disabled_deciders[name] and name ~= lastWinner then
Asa@74 347 newDecision, reason = decider(data)
Asa@74 348
Asa@59 349 if newDecision > data.queue then
Asa@59 350 data.queue = newDecision
Asa@74 351 lastWinner = (reason or name)
Asa@59 352 return Decide(data)
Asa@59 353 elseif newDecision < 0 then
Asa@59 354 lastWinner = ""
Asa@74 355 return 'VETO: '..(reason or name), -1
Asa@59 356 end
Asa@59 357 end
Asa@59 358 end
Asa@59 359
Asa@59 360 winner = lastWinner
Asa@59 361 lastWinner = ""
Asa@59 362
Asa@77 363 data.queue = ceil(data.queue / GetTradeSkillNumMade(data.tradeSkillIndex))
Asa@77 364
Asa@59 365 return winner, data.queue
Asa@59 366 end
Asa@59 367
Asa@59 368 local function isProfitable(data)
Asa@59 369 if data.profit > 0 and data.profit > ItemAuditor:GetCraftingThreshold() then
Asa@59 370 return 1
Asa@59 371 end
Asa@99 372 return -1, 'Not Profitable'
Asa@59 373 end
Asa@72 374
Asa@64 375 Crafting.RegisterCraftingDecider('Is Profitable', isProfitable)
Asa@59 376
Asa@74 377
Asa@59 378
Asa@59 379 local tableData = {}
Asa@59 380 function ItemAuditor:UpdateCraftingTable()
Asa@59 381 if LSW == nil then
Asa@59 382 self:Print("This feature requires LilSparky's Workshop.")
Asa@59 383 return
Asa@59 384 end
Asa@59 385 if GetAuctionBuyout ~= nil then
Asa@59 386 elseif AucAdvanced and AucAdvanced.Version then
Asa@59 387 else
Asa@59 388 self:Print("This feature requires Auctionator, Auctioneer, AuctionLite, or AuctionMaster.")
Asa@59 389 return
Asa@59 390 end
Asa@59 391 wipe(realData)
Asa@59 392 wipe(tableData)
Asa@59 393
Asa@59 394 local profitableItems = {}
Asa@59 395 local profitableIndex = 1
Asa@59 396 local numChecked = 0
Asa@59 397 local row = 1
Asa@59 398
Asa@59 399 for i = 1, GetNumTradeSkills() do
Asa@59 400 local itemLink = GetTradeSkillItemLink(i)
Asa@86 401 local itemId = Utils.GetItemID(itemLink)
Asa@59 402
Asa@59 403 --Figure out if its an enchant or not
Asa@59 404 _, _, _, _, altVerb = GetTradeSkillInfo(i)
Asa@59 405 if LSW.scrollData[itemId] ~= nil and altVerb == 'Enchant' then
Asa@59 406 -- Ask LSW for the correct scroll
Asa@59 407 itemId = LSW.scrollData[itemId]["scrollID"]
Asa@59 408 end
Asa@59 409
Asa@59 410 local recipeLink = GetTradeSkillRecipeLink(i)
Asa@59 411 local stackSize = 1
Asa@59 412 if recipeLink ~= nil and itemId ~= nil then
Asa@59 413 local skillName, skillType, numAvailable, isExpanded, altVerb = GetTradeSkillInfo(i)
Asa@59 414 local itemName, itemLink= GetItemInfo(itemId)
Asa@74 415
Asa@74 416 -- This check has to be here for things like Inscription Research that don't produce an item.
Asa@74 417 if itemLink then
Asa@82 418 local count = ItemAuditor:GetItemCount(itemId)
Asa@74 419 local reagents = {}
Asa@74 420 local totalCost = 0
Asa@74 421 for reagentId = 1, GetTradeSkillNumReagents(i) do
Asa@74 422 local reagentName, _, reagentCount = GetTradeSkillReagentInfo(i, reagentId);
Asa@74 423 local reagentLink = GetTradeSkillReagentItemLink(i, reagentId)
Asa@74 424
Asa@74 425 reagents[reagentId] = {
Asa@93 426 link = reagentLink,
Asa@74 427 name = reagentName,
Asa@74 428 count = reagentCount,
Asa@74 429 price = self:GetReagentCost(reagentLink, reagentCount),
Asa@94 430 need = 0, -- This will get populated after the decisions have been made. it can't
Asa@94 431 -- be done before that because highest profit items get priority on materials.
Asa@74 432 }
Asa@74 433 totalCost = totalCost + self:GetReagentCost(reagentLink, reagentCount)
Asa@74 434 end
Asa@74 435 local data = {
Asa@74 436 recipeLink = recipeLink,
Asa@95 437 recipeID = Utils.GetItemID(recipeLink),
Asa@74 438 link = itemLink,
Asa@74 439 name = itemName,
Asa@74 440 count = count,
Asa@74 441 price = (self:GetAuctionPrice(itemLink) or 0),
Asa@74 442 cost = totalCost,
Asa@74 443 profit = (self:GetAuctionPrice(itemLink) or 0) - totalCost,
Asa@74 444 reagents = reagents,
Asa@74 445 count = count,
Asa@74 446 tradeSkillIndex = i,
Asa@74 447 queue = 0,
Asa@74 448 winner = "",
Asa@74 449 }
Asa@59 450
Asa@74 451 data.winner, data.queue = Decide(data)
Asa@99 452 --[[
Asa@99 453 If it wasn't vetoed we need to reduce the number by how many are owned
Asa@99 454 but this should not go below 0
Asa@99 455 ]]
Asa@99 456 if data.queue > 0 then
Asa@99 457 data.queue = max(0, data.queue - count)
Asa@99 458 end
Asa@74 459
Asa@74 460 -- If a tradeskill makes 5 at a time and something asks for 9, we should only
Asa@74 461 -- craft twice to get 10.
Asa@74 462 data.queue = ceil(data.queue / GetTradeSkillNumMade(i))
Asa@74 463
Asa@74 464 realData[row] = data
Asa@74 465 row = row + 1
Asa@59 466 end
Asa@59 467 end
Asa@59 468 end
Asa@99 469 table.sort(realData, function(a, b) return a.profit*max(1, a.queue) > b.profit*max(1, b.queue) end)
Asa@94 470
Asa@94 471 local numOwned = {}
Asa@94 472 for key, data in pairs(realData) do
Asa@94 473 data.haveMaterials = true
Asa@94 474 for id, reagent in pairs(data.reagents) do
Asa@94 475 if not numOwned[reagent.link] then
Asa@94 476 numOwned[reagent.link] = ItemAuditor:GetItemCount(ItemAuditor:GetIDFromLink(reagent.link))
Asa@94 477 end
Asa@94 478 numOwned[reagent.link] = numOwned[reagent.link] - reagent.count
Asa@94 479
Asa@94 480 if numOwned[reagent.link] < 0 then
Asa@94 481 data.haveMaterials = false
Asa@94 482 reagent.need = min(reagent.count, abs(numOwned[reagent.link]))
Asa@94 483 end
Asa@94 484 end
Asa@94 485 end
Asa@94 486
Asa@68 487 if craftingTable then
Asa@68 488 craftingTable:SetFilter(tableFilter)
Asa@68 489 self:RefreshCraftingTable()
Asa@68 490 end
Asa@60 491 end
Asa@60 492
Asa@60 493 function ItemAuditor:RefreshCraftingTable()
Asa@99 494 local displayMaterials
Asa@59 495 for key, data in pairs(realData) do
Asa@99 496 displayMaterials = 'n'
Asa@99 497 if data.haveMaterials then
Asa@99 498 displayMaterials = 'y'
Asa@99 499 end
Asa@59 500 tableData[key] = {
Asa@59 501 data.name,
Asa@59 502 data.cost,
Asa@59 503 data.price,
Asa@59 504 data.winner,
Asa@99 505 abs(data.queue),
Asa@99 506 displayMaterials,
Asa@99 507 data.profit*abs(data.queue),
Asa@59 508 }
Asa@59 509 end
Asa@60 510 craftingTable:SetData(tableData, true)
Asa@59 511
Asa@60 512 if self:GetCraftingRow(1) then
Asa@60 513 btnProcess:Enable()
Asa@60 514 else
Asa@60 515 btnProcess:Disable()
Asa@60 516 end
Asa@59 517 end
Asa@59 518
Asa@59 519 function ItemAuditor:GetCraftingRow(row)
Asa@59 520 if craftingTable then
Asa@59 521 for _, index in pairs(craftingTable.sorttable) do
Asa@59 522 local tableRow = tableData[index]
Asa@59 523 if tableFilter(nil, tableRow) then
Asa@59 524 row = row - 1
Asa@59 525 if row == 0 then
Asa@59 526 return realData[index]
Asa@59 527 end
Asa@59 528 end
Asa@59 529 end
Asa@59 530 elseif realData then
Asa@59 531 return realData[row]
Asa@59 532 end
Asa@59 533 return nil
Asa@59 534 end
Asa@67 535 ItemAuditor.Options.args.crafting = {
Asa@67 536 type = "execute",
Asa@67 537 name = "crafting",
Asa@67 538 desc = "This opens a window to configure a crafting queue.",
Asa@67 539 func = "DisplayCrafting",
Asa@67 540 guiHidden = false,
Asa@67 541 }