Mercurial > wow > askmrrobot
comparison AskMrRobot.lua @ 21:a400b906acca v4
Version 4: fixed an issue with the bank. Added Void Storage. Added Reagent Bank.
Also removed stackable items from the export string
author | Adam tegen <adam.tegen@gmail.com> |
---|---|
date | Wed, 15 Oct 2014 08:38:53 -0500 |
parents | e77e01abce98 |
children | 3af56b6545e0 |
comparison
equal
deleted
inserted
replaced
20:e6cd96d23c5a | 21:a400b906acca |
---|---|
25 AskMrRobot.eventListener:RegisterEvent("PLAYER_REGEN_DISABLED") | 25 AskMrRobot.eventListener:RegisterEvent("PLAYER_REGEN_DISABLED") |
26 --AskMrRobot.eventListener:RegisterEvent("ENCOUNTER_START") | 26 --AskMrRobot.eventListener:RegisterEvent("ENCOUNTER_START") |
27 AskMrRobot.eventListener:RegisterEvent("CHAT_MSG_ADDON") | 27 AskMrRobot.eventListener:RegisterEvent("CHAT_MSG_ADDON") |
28 AskMrRobot.eventListener:RegisterEvent("UPDATE_INSTANCE_INFO") | 28 AskMrRobot.eventListener:RegisterEvent("UPDATE_INSTANCE_INFO") |
29 AskMrRobot.eventListener:RegisterEvent("PLAYER_DIFFICULTY_CHANGED") | 29 AskMrRobot.eventListener:RegisterEvent("PLAYER_DIFFICULTY_CHANGED") |
30 AskMrRobot.eventListener:RegisterEvent("VOID_STORAGE_OPEN") | |
31 AskMrRobot.eventListener:RegisterEvent("VOID_STORAGE_CONTENTS_UPDATE") | |
32 AskMrRobot.eventListener:RegisterEvent("PLAYER_DIFFICULTY_CHANGED") | |
33 AskMrRobot.eventListener:RegisterEvent("VOID_STORAGE_UPDATE") | |
30 | 34 |
31 AskMrRobot.AddonName = ... | 35 AskMrRobot.AddonName = ... |
32 AskMrRobot.ChatPrefix = "_AMR" | 36 AskMrRobot.ChatPrefix = "_AMR" |
33 | 37 |
34 -- the main user interface window | 38 -- the main user interface window |
39 | 43 |
40 function AskMrRobot.eventListener:OnEvent(event, ...) | 44 function AskMrRobot.eventListener:OnEvent(event, ...) |
41 if event == "ADDON_LOADED" then | 45 if event == "ADDON_LOADED" then |
42 local addon = select(1, ...) | 46 local addon = select(1, ...) |
43 if (addon == "AskMrRobot") then | 47 if (addon == "AskMrRobot") then |
44 --print(L.AMR_ON_EVENT_LOADED:format(GetAddOnMetadata(AskMrRobot.AddonName, "Version"))) | |
45 | |
46 AskMrRobot.InitializeSettings() | 48 AskMrRobot.InitializeSettings() |
47 AskMrRobot.InitializeMinimap() | 49 AskMrRobot.InitializeMinimap() |
48 | 50 |
49 -- listen for messages from other AMR addons | 51 -- listen for messages from other AMR addons |
50 RegisterAddonMessagePrefix(AskMrRobot.ChatPrefix) | 52 RegisterAddonMessagePrefix(AskMrRobot.ChatPrefix) |
64 --AskMrRonot.GetCurrencies(); | 66 --AskMrRonot.GetCurrencies(); |
65 --AskMrRobot.GetGold(); | 67 --AskMrRobot.GetGold(); |
66 | 68 |
67 elseif event == "BANKFRAME_OPENED" or event == "PLAYERBANKSLOTS_CHANGED" then | 69 elseif event == "BANKFRAME_OPENED" or event == "PLAYERBANKSLOTS_CHANGED" then |
68 AskMrRobot.ScanBank(); | 70 AskMrRobot.ScanBank(); |
69 | 71 elseif event == "VOID_STORAGE_OPEN" or event == "VOID_STORAGE_CONTENTS_UPDATE" or event == "VOID_STORAGE_DEPOSIT_UPDATE" or event == "VOID_STORAGE_UPDATE" then |
72 AskMrRobot.ScanVoidStorage(); | |
70 elseif event == "CHARACTER_POINTS_CHANGED" or event == "CONFIRM_TALENT_WIPE" or event == "PLAYER_TALENT_UPDATE" or event == "ACTIVE_TALENT_GROUP_CHANGED" then | 73 elseif event == "CHARACTER_POINTS_CHANGED" or event == "CONFIRM_TALENT_WIPE" or event == "PLAYER_TALENT_UPDATE" or event == "ACTIVE_TALENT_GROUP_CHANGED" then |
71 --AskMrRobot.GetAmrSpecializations(); | 74 --AskMrRobot.GetAmrSpecializations(); |
72 --if AskMrRobot_ReforgeFrame then | 75 --if AskMrRobot_ReforgeFrame then |
73 -- AskMrRobot_ReforgeFrame:OnUpdate() | 76 -- AskMrRobot_ReforgeFrame:OnUpdate() |
74 --end | 77 --end |
251 end | 254 end |
252 | 255 |
253 | 256 |
254 function AskMrRobot.SaveAll() | 257 function AskMrRobot.SaveAll() |
255 AskMrRobot.ScanCharacter() | 258 AskMrRobot.ScanCharacter() |
256 AskMrRobot.ScanBank() | |
257 AskMrRobot.ScanBags() | 259 AskMrRobot.ScanBags() |
258 AskMrRobot.ScanEquipped() | 260 AskMrRobot.ScanEquipped() |
259 AskMrRobot.GetCurrencies() | 261 AskMrRobot.GetCurrencies() |
260 AskMrRobot.GetReputations() | 262 AskMrRobot.GetReputations() |
261 AskMrRobot.GetSpecs() | 263 AskMrRobot.GetSpecs() |
371 end | 373 end |
372 end | 374 end |
373 end | 375 end |
374 end | 376 end |
375 | 377 |
376 function AskMrRobot.ScanBank(bankItemsWithCount) | 378 function AskMrRobot.ScanBank() |
379 --REAGENTBANK_CONTAINER (-3) | |
377 local bankItems = {} | 380 local bankItems = {} |
378 local bankItemsAndCounts = {} | 381 local bankItemsAndCounts = {} |
379 | 382 |
380 scanBag(BANK_CONTAINER, true, bankItems, bankItemsAndCounts) | 383 scanBag(BANK_CONTAINER, true, bankItems, bankItemsAndCounts) |
384 scanBag(REAGENTBANK_CONTAINER, true, bankItems, bankItemsAndCounts) | |
381 for bagId = NUM_BAG_SLOTS + 1, NUM_BAG_SLOTS + NUM_BANKBAGSLOTS do | 385 for bagId = NUM_BAG_SLOTS + 1, NUM_BAG_SLOTS + NUM_BANKBAGSLOTS do |
382 scanBag(bagId, true, bankItems, bankItemsAndCounts) | 386 scanBag(bagId, true, bankItems, bankItemsAndCounts) |
383 end | 387 end |
384 | 388 |
385 -- see if the scan completed before the window closed, otherwise we don't overwrite with partial data | 389 -- see if the scan completed before the window closed, otherwise we don't overwrite with partial data |
387 local itemLink = GetContainerItemLink(_lastBankBagId, _lastBankSlotId) | 391 local itemLink = GetContainerItemLink(_lastBankBagId, _lastBankSlotId) |
388 if itemLink ~= nil then --still open | 392 if itemLink ~= nil then --still open |
389 AmrDb.BankItems = bankItems | 393 AmrDb.BankItems = bankItems |
390 AmrDb.BankItemsAndCounts = bankItemsAndCounts | 394 AmrDb.BankItemsAndCounts = bankItemsAndCounts |
391 end | 395 end |
396 end | |
397 end | |
398 | |
399 function AskMrRobot.ScanVoidStorage() | |
400 if IsVoidStorageReady() then | |
401 local voidItems = {} | |
402 local VOID_STORAGE_MAX = 80 | |
403 local VOID_STORAGE_PAGES = 2 | |
404 local i | |
405 for page = 1,VOID_STORAGE_PAGES do | |
406 for i = 1,VOID_STORAGE_MAX do | |
407 local itemId = GetVoidItemInfo(page, i) | |
408 if itemId then | |
409 local itemLink = GetVoidItemHyperlinkString(page, i); | |
410 if itemLink then | |
411 tinsert(voidItems, itemLink) | |
412 end | |
413 end | |
414 end | |
415 end | |
416 AmrDb.VoidItems = voidItems | |
392 end | 417 end |
393 end | 418 end |
394 | 419 |
395 function AskMrRobot.ScanBags(bagItemsWithCount) | 420 function AskMrRobot.ScanBags(bagItemsWithCount) |
396 local bagItems = {} | 421 local bagItems = {} |
691 | 716 |
692 -- export bag and bank | 717 -- export bag and bank |
693 local itemObjects = {} | 718 local itemObjects = {} |
694 if AmrDb.BagItems then | 719 if AmrDb.BagItems then |
695 for i, v in ipairs(AmrDb.BagItems) do | 720 for i, v in ipairs(AmrDb.BagItems) do |
696 local itemData = AskMrRobot.parseItemLink(v) | 721 local _,_,_,_,_,_,_,stackCount = GetItemInfo(v) |
697 if itemData ~= nil then | 722 if stackCount == 1 then |
698 table.insert(itemObjects, itemData) | 723 local itemData = AskMrRobot.parseItemLink(v) |
699 end | 724 if itemData ~= nil then |
725 table.insert(itemObjects, itemData) | |
726 end | |
727 end | |
700 end | 728 end |
701 end | 729 end |
702 if AmrDb.BankItems then | 730 if AmrDb.BankItems then |
703 for i, v in ipairs(AmrDb.BankItems) do | 731 for i, v in ipairs(AmrDb.BankItems) do |
704 local itemData = AskMrRobot.parseItemLink(v) | 732 local _,_,_,_,_,_,_,stackCount = GetItemInfo(v) |
705 if itemData ~= nil then | 733 if stackCount == 1 then |
706 table.insert(itemObjects, itemData) | 734 local itemData = AskMrRobot.parseItemLink(v) |
735 if itemData ~= nil then | |
736 table.insert(itemObjects, itemData) | |
737 end | |
707 end | 738 end |
708 end | 739 end |
740 end | |
741 if AmrDb.VoidItems then | |
742 for i, v in ipairs(AmrDb.VoidItems) do | |
743 local _,_,_,_,_,_,_,stackCount = GetItemInfo(v) | |
744 if stackCount == 1 then | |
745 local itemData = AskMrRobot.parseItemLink(v) | |
746 if itemData ~= nil then | |
747 table.insert(itemObjects, itemData) | |
748 end | |
749 end | |
750 end | |
709 end | 751 end |
710 | 752 |
711 table.insert(fields, ".inv") | 753 table.insert(fields, ".inv") |
712 appendItemsToExport(fields, itemObjects) | 754 appendItemsToExport(fields, itemObjects) |
713 end | 755 end |