As I understand it, bank sorting has been abandoned because of a bug in the notify. Does anyone know of a currently working bank/char item sorting macro? If not, is the specific reason known?
| http://www.macroquest2.com/phpBB2/viewtopic.php?t=13795
|
| BankSort.mac - V1.02 A MQ2 Related Macro Source File
|
| COMMENT: Based on previous MQ2 macros, CSort.mac by Agripa
| SortBank by Fury and other MQ2 macro contributors.
|
| NOTES: Macro sorts items by name. Sorts items stored in
| containers in bank slots. Macro only deals with items
| within containers. Macro does not currently handle
| items that may not fit in particular sized containers.
| For example, attempting to place a large item in a small
| container.
|
| USAGE: /mac BankSort
| Must have bank window open before execution
|
| HISTORY:
| 1.02 - 20060912 Added Auto-Bank option, portilicious
| 1.01 - 20060905 Corrected array issue PoR slots, portilicious
| 1.00 - 20060904 Initial Labor Day Release, portilicious
|
#turbo 40
#define /mqlog /echo
#define DEBUG 0
#define DEBUG_1 "/squelch /mqlog"
#define SLOTOFFSET 2030
Sub Main
| Change the UseEmptySlots bool below to FALSE to not
| use available empty slots and only swap slots with items.
/declare UseEmptySlots bool outer TRUE
| Try to auto bank items before sorting to optimize bank space
/declare AutoBank bool outer TRUE
| Variables below here do not need to be modified
/declare UseBigBankWnd bool outer FALSE
/declare ItemCount int outer 0
/declare ItemsCounted int outer 0
/declare EmptySlotCount int outer 0
/declare BankSlots int outer 0
/declare BankItems int outer 0
/popup Running...
/echo Running...
/call SetBankSlotCount
/varset BankItems ${Int[${Math.Calc[10*${BankSlots}]}]}
/declare FreeSlotIDArray[${BankItems}] int outer 0
/declare BankItemArray[${BankItems},4] string outer -1
/call OpenAllBankContainers
/if (${AutoBank}) /call DoAutoBank
/call InitBankItemArray
/if (${Bool[DEBUG]}) /call ShowFreeSlotIDArray
/if (${Bool[DEBUG]}) /call ShowBankItemArray
/call SortFreeSlotIDs ${EmptySlotCount}
/call SortByItemName ${ItemCount}
/call PopulateDestSlotInfo
/if (${Bool[DEBUG]}) /call ShowBankItemArray
/if (${Bool[DEBUG]}) /call ShowFreeSlotIDArray
/call DoSwap
/popup Total run time ${Macro.RunTime} seconds
/echo Processed ${ItemsCounted} items.
/echo Total run time ${Macro.RunTime} seconds.
/echo Done.
/return
|---------------------------------------------------------
|SUB: Check for open Bank Window and Set Bank Slot Count
|---------------------------------------------------------
Sub SetBankSlotCount
/if (${Window[BankWnd].Open}) {
/varset BankSlots 16
} else {
/if (${Window[BigBankWnd].Open}) {
/varset UseBigBankWnd TRUE
/varset BankSlots 24
} else {
/echo ERROR -- Bank window not open, ending macro!
/endmacro
}
}
/return
|---------------------------------------------------------
|SUB: Open All Bank Containers
|---------------------------------------------------------
Sub OpenAllBankContainers
/declare i int local 1
/for i 1 to ${BankSlots}
/if (${Int[${Me.Bank[${i}].Container}]}) {
/if (!${Window[bank${i}].Open}) {
/nomodkey /itemnotify bank${i} rightmouseup
/delay 5s ${Window[bank${i}].Open}
}
/if (!${Window[bank${i}].Open}) /echo ERROR -- Possible problem opening bank container at # ${i}.
/delay 2
}
/next i
/return 1
|---------------------------------------------------------
|SUB: Do Swap - Main Swap of Bank Items
|---------------------------------------------------------
Sub DoSwap
/declare i int local 1
/declare j int local ${ItemCount}
/declare MeBankItemID int local 0
/declare MeBankItemName string local -1
/declare ToBankSlotID int local 0
/declare FromBankSlotID int local 0
/if (${ItemCount}<2) /return
/if (!${UseEmptySlots}) /varcalc j ${j}-1
/for i 1 to ${j}
/if (!(${i}%5)) /popup ${Int[${Math.Calc[${i}/${j}*100]}]}% complete, run time ${Macro.RunTime} seconds
/call PopBankItemArray
/varset MeBankItemID ${Int[${Macro.Return.Token[1,,]}]}
/varset MeBankItemName ${Macro.Return.Token[2,,]}
/varset FromBankSlotID ${Int[${Macro.Return.Token[3,,]}]}
/varset ToBankSlotID ${Int[${Macro.Return.Token[4,,]}]}
DEBUG_1 i: ${i} [${MeBankItemID}] ${MeBankItemName} [${ToBankSlotID}] [${FromBankSlotID}]
/echo Picking up ${MeBankItemName} from slot ID ${FromBankSlotID} moving to slot ID ${ToBankSlotID}
/call SwapAndUpdateInfo ${FromBankSlotID} ${ToBankSlotID}
/delay 5
/next i
/return
|---------------------------------------------------------
|SUB: Swap and Update Slot Information
|---------------------------------------------------------
Sub SwapAndUpdateInfo(int FromSlotID, int ToSlotID)
/declare n int local 0
/if (${FromSlotID}==${ToSlotID}) {
DEBUG_1 From Slot ID [${FromSlotID}] is the same as To Slot ID [${ToSlotID})], not swapping.
/return
}
/if (${InvSlot[${FromSlotID}].Item.ID}==${InvSlot[${ToSlotID}].Item.ID}) {
DEBUG_1 From Slot ID [${FromSlotID}] and To Slot ID [${ToSlotID})] contain same type of item, not swapping.
/return
}
/call SlotHasItem ${ToSlotID}
/if (${Macro.Return}) {
/call FindItemInSlot ${ToSlotID}
/varset n ${Int[${Macro.Return}]}
/if (${Bool[${n}]}) /varset BankItemArray[${n},3]} ${FromSlotID}
}
/call SwapItemInSlots ${FromSlotID} ${ToSlotID}
/return
|---------------------------------------------------------
|SUB: Sawp Items In Slots From Slot To Slot
|---------------------------------------------------------
Sub SwapItemInSlots(int FromSlotID, int ToSlotID)
/echo Moving item from Slot ID #${FromSlotID} to slot ID #${ToSlotID}
/call PickUpItem ${FromSlotID}
/call PutItemInSlotNumber ${ToSlotID} TRUE
/if (${Cursor.ID}) {
/delay 5
/call PutItemInSlotNumber ${FromSlotID} TRUE
}
/return
|---------------------------------------------------------
|SUB: Find Item In Slot
|---------------------------------------------------------
Sub FindItemInSlot(int SlotID)
/declare i int local 1
/for i 1 to ${ItemCount}
/if (${Int[${BankItemArray[${i},3]}]}==${SlotID}) /return ${i}
/next i
/return 0
|---------------------------------------------------------
|SUB: Do Auto Bank
|---------------------------------------------------------
Sub DoAutoBank
/declare i int local 1
/declare j int local 1
/declare Slots int local 0
/declare SlotNum int local 0
/echo Performing Auto-Bank...
/for i 1 to ${BankSlots}
/popup Performing Auto-Bank, run time ${Macro.RunTime} seconds
/if (${Int[${Me.Bank[${i}].Container}]}) {
/varset Slots ${Int[${Me.Bank[${i}].Container}]}
/for j 1 to ${Slots}
/if (${Bool[${Me.Bank[${i}].Item[${j}]}]}) {
/varset SlotNum ${Int[${Me.Bank[${i}].Item[${j}].InvSlot}]}
/call PickUpItem ${SlotNum}
/if (${UseBigBankWnd}) {
/notify BigBankWnd bigb_autobutton leftmouseup
} else {
/notify BankWnd bw_autobutton leftmouseup
}
/delay 3
/if (${Cursor.ID}) /call PutItemInSlotNumber ${SlotNum} FALSE
}
/next j
}
/next i
/return
|---------------------------------------------------------
|SUB: Initialize Bank Item Array
|---------------------------------------------------------
Sub InitBankItemArray
/declare i int local 1
/declare j int local 1
/declare Slot int local 0
/for i 1 to ${BankSlots}
/if (${Int[${Me.Bank[${i}].Container}]}) {
/varset Slot ${Int[${Me.Bank[${i}].Container}]}
DEBUG_1 Bank slot ${i} has a container that has ${Int[${Me.Bank[${i}].Container}]} slots.
/for j 1 to ${Slot}
/if (${Bool[${Me.Bank[${i}].Item[${j}]}]}) {
DEBUG_1 Inventory Slot #: ${Me.Bank[${i}].Item[${j}].InvSlot} Item Name: ${Me.Bank[${i}].Item[${j}].Name} ID #${Me.Bank[${i}].Item[${j}].ID}
/varcalc ItemCount ${ItemCount}+1
/varcalc EmptySlotCount ${EmptySlotCount}+1
/varset FreeSlotIDArray[${EmptySlotCount}] ${Int[${Me.Bank[${i}].Item[${j}].InvSlot}]}
/varset BankItemArray[${ItemCount},1] ${Me.Bank[${i}].Item[${j}].ID}
/varset BankItemArray[${ItemCount},2] ${Me.Bank[${i}].Item[${j}].Name}
/varset BankItemArray[${ItemCount},3] ${Int[${Me.Bank[${i}].Item[${j}].InvSlot}]}
/varset BankItemArray[${ItemCount},4] 0
} else {
/if (${UseEmptySlots}) {
/varcalc EmptySlotCount ${EmptySlotCount}+1
/varset FreeSlotIDArray[${EmptySlotCount}] ${Int[${Math.Calc[(${i}-1)*10+${j}+SLOTOFFSET]}]}
}
}
/next j
}
/next i
/varset ItemsCounted ${ItemCount}
/return
|---------------------------------------------------------
|SUB: Popluate Destination Slot Information
|---------------------------------------------------------
Sub PopulateDestSlotInfo
/declare i int local 1
/for i 1 to ${ItemCount}
/varset BankItemArray[${i},4] ${Int[${FreeSlotIDArray[${i}]}]}
/next i
/return
|---------------------------------------------------------
|SUB: Pop Bank Item Array
|---------------------------------------------------------
Sub PopBankItemArray
/declare i int local 1
/declare Element string local -1
/if (${ItemCount}<1) /return 0
/varset Element ${BankItemArray[${i},1]},${BankItemArray[${i},2]},${BankItemArray[${i},3]},${BankItemArray[${i},4]}
/for i 1 to ${ItemCount}
/varset BankItemArray[${i},1] ${BankItemArray[${Math.Calc[${i}+1]},1]}
/varset BankItemArray[${i},2] ${BankItemArray[${Math.Calc[${i}+1]},2]}
/varset BankItemArray[${i},3] ${BankItemArray[${Math.Calc[${i}+1]},3]}
/varset BankItemArray[${i},4] ${BankItemArray[${Math.Calc[${i}+1]},4]}
/next i
/varcalc ItemCount ${ItemCount}-1
/return ${Element}
|---------------------------------------------------------
|SUB: Show Bank Item Array
|---------------------------------------------------------
Sub ShowBankItemArray
/declare i int local 1
/echo [Item_ID] Item_Name [To_Slot] [From_Slot]
/for i 1 to ${ItemCount}
/call ShowBankItem ${i}
/next i
/return
|---------------------------------------------------------
|SUB: Show Bank Item in Bank Item Array
|---------------------------------------------------------
Sub ShowBankItem(int n)
/echo ${n}> [${BankItemArray[${n},1]}] ${BankItemArray[${n},2]} [${BankItemArray[${n},3]}] [${BankItemArray[${n},4]}]
/return
|---------------------------------------------------------
|SUB: Put Item In Slot Number Using Slot ID
|---------------------------------------------------------
Sub PutItemInSlotNumber(int SlotID, bool UseShiftKey)
DEBUG_1 Placing Cursor Item ${Cursor.Name} [${Cursor.ID}] Slot ID: #${SlotID} ShiftKey: ${UseShiftKey}
/if (${UseShiftKey}) {
/nomodkey /shiftkey /itemnotify ${SlotID} leftmouseup
} else {
/nomodkey /itemnotify ${SlotID} leftmouseup
}
/delay 1s ${InvSlot[${SlotID}].Item.ID}
/return
|---------------------------------------------------------
|SUB: Pick Up Item
|---------------------------------------------------------
Sub PickUpItem(int SlotID)
/call SlotHasItem ${SlotID}
/if (!${Macro.Return}) {
DEBUG_1 Bank Slot ID [${SlotID}] is empty.
/return 0
} else {
/nomodkey /shiftkey /itemnotify ${SlotID} leftmouseup
/delay 1s ${Cursor.ID}
}
/return 1
|---------------------------------------------------------
|SUB: Does Bank Slot Have an Item
|---------------------------------------------------------
Sub SlotHasItem(int SlotID)
/if (${Bool[${InvSlot[${SlotID}].Item.ID}]}) /return 1
/return 0
|---------------------------------------------------------
|SUB: Shell Sort By Item Name
|---------------------------------------------------------
Sub SortByItemName(int ArraySize)
/declare StrTemp1 string local -1
/declare StrTemp2 string local -1
/declare StrTemp3 string local -1
/declare StrTemp4 string local -1
/declare GapSize int local 0
/declare i int local 1
/declare CurPos int local 1
/if (${ArraySize}<2) /return
:DoLoop1
/varcalc GapSize ${GapSize}*3+1
/if (${GapSize}<=${ArraySize}) /goto :DoLoop1
:DoLoop2
/varcalc GapSize ${GapSize}\3
/if (${Int[${Math.Calc[${GapSize}+1]}]}<=${ArraySize}) {
/popup Sorting item names, run time ${Macro.RunTime} seconds
/for i ${Int[${Math.Calc[${GapSize}+1]}]} to ${ArraySize}
/varset CurPos ${i}
/varset StrTemp1 ${BankItemArray[${i},1]}
/varset StrTemp2 ${BankItemArray[${i},2]}
/varset StrTemp3 ${BankItemArray[${i},3]}
/varset StrTemp4 ${BankItemArray[${i},4]}
:DoLoop3
/call StrCmp "${BankItemArray[${Int[${Math.Calc[${CurPos}-${GapSize}]}]},2]}" "${StrTemp2}"
/if (${Macro.Return}==1) {
/varset BankItemArray[${CurPos},1] ${BankItemArray[${Int[${Math.Calc[${CurPos}-${GapSize}]}]},1]}
/varset BankItemArray[${CurPos},2] ${BankItemArray[${Int[${Math.Calc[${CurPos}-${GapSize}]}]},2]}
/varset BankItemArray[${CurPos},3] ${BankItemArray[${Int[${Math.Calc[${CurPos}-${GapSize}]}]},3]}
/varset BankItemArray[${CurPos},4] ${BankItemArray[${Int[${Math.Calc[${CurPos}-${GapSize}]}]},4]}
/varcalc CurPos ${CurPos}-${GapSize}
/if (${Int[${Math.Calc[${CurPos}-${GapSize}]}]}>=1) /goto :DoLoop3
}
/varset BankItemArray[${CurPos},1] ${StrTemp1}
/varset BankItemArray[${CurPos},2] ${StrTemp2}
/varset BankItemArray[${CurPos},3] ${StrTemp3}
/varset BankItemArray[${CurPos},4] ${StrTemp4}
/next i
}
/if (${GapSize}!=1) /goto :DoLoop2
/return
|---------------------------------------------------------
|SUB: String Compare (Compare Wrapper)
|---------------------------------------------------------
Sub StrCmp(string S1, string S2)
/if (${S1.Compare[${S2}]}<0) {
DEBUG_1 S1 ${S1} is less than S2 ${S2}
/return -1
} else {
/if (${S1.Compare[${S2}]}>0) {
DEBUG_1 S1 ${S1} is greater than S2 ${S2}
/return 1
}
}
DEBUG_1 S1 ${S1} is the same as S2 ${S2}
/return 0
|---------------------------------------------------------
|SUB: Show Free Slot ID Array
|---------------------------------------------------------
Sub ShowFreeSlotIDArray
/declare i int local 1
/for i 1 to ${EmptySlotCount}
/echo ${i}> [${FreeSlotIDArray[${i}]}]
/next i
/return
|---------------------------------------------------------
|SUB: Shell Sort Free Slot ID's
|---------------------------------------------------------
Sub SortFreeSlotIDs(int ArraySize)
/declare iTemp1 int local 0
/declare GapSize int local 0
/declare i int local 1
/declare CurPos int local 1
:DoLoop1
/varcalc GapSize ${GapSize}*3+1
/if (${GapSize}<=${ArraySize}) /goto :DoLoop1
:DoLoop2
/varcalc GapSize ${GapSize}\3
/if (${Int[${Math.Calc[${GapSize}+1]}]}<=${ArraySize}) {
/popup Sorting available slot numbers, run time ${Macro.RunTime} seconds
/for i ${Int[${Math.Calc[${GapSize}+1]}]} to ${ArraySize}
/varset CurPos ${i}
/varset iTemp1 ${FreeSlotIDArray[${i}]}
:DoLoop3
/if (${FreeSlotIDArray[${Int[${Math.Calc[${CurPos}-${GapSize}]}]}]}>${iTemp1}) {
/varset FreeSlotIDArray[${CurPos}] ${FreeSlotIDArray[${Int[${Math.Calc[${CurPos}-${GapSize}]}]}]}
/varcalc CurPos ${CurPos}-${GapSize}
/if (${Int[${Math.Calc[${CurPos}-${GapSize}]}]}>=1) /goto :DoLoop3
}
/varset FreeSlotIDArray[${CurPos}] ${iTemp1}
/next i
}
/if (${GapSize}!=1) /goto :DoLoop2
/return
I looked over different sort macros. I know part of the problems are this was written when bags had only 10 slots (cap) and we had 16 bank slots and 8 personal slots.
I doubt they'd care, but I don't want to break any vip rules from macroquest2...the macro I used is invsort.mac from this set of invutils:
MacroQuest - Login
Way back in the day. Someone wrote a very cool set of item handling macros that let you come back to base:
1) Dump all the stuff you want to save to a mule.
2) Sell all the stuff you have marked sell.
3) Sort your bank
4) Run the mule(s) in a get me "This" item mode. ( Really slick way to make space for your TS stuff )
I attempted to get them working again but the switch between 10 slot bag methods and big bag methods did not work.
I'm sure given enough motivation I could get them working again.
Sadly, I'm not sure what would motive me enough
/itemnotify ${Me.Bank[#].Item[#].InvSlot.ID} leftmouseup
I am rusty on this subject, but iirc you need .ItemSlot plus 1...
I can't check right now, not at home.
htw
Way back in the day. Someone wrote a very cool set of item handling macros that let you come back to base:
1) Dump all the stuff you want to save to a mule.
2) Sell all the stuff you have marked sell.
3) Sort your bank
4) Run the mule(s) in a get me "This" item mode. ( Really slick way to make space for your TS stuff )
I attempted to get them working again but the switch between 10 slot bag methods and big bag methods did not work.
I'm sure given enough motivation I could get them working again.
Sadly, I'm not sure what would motive me enough
So I'm no professional programmer and my fiance demanded my time quite a bit in the past two days. I've got a functional sorter, but it's probably not as expected thus far. I only got to spend about 3 hours doing this. Currently it only sorts each bag alphabetically...individually. I could have made arrays and done the entire inventory. To be honest I was so busy learning the syntax needed to compare strings since the ${String.Compare[String2]} is returning unexpected results I had to create my own means of comparing strings with length greater than 1, that I didn't have time to learn how to use arrays in macros. It's certainly very crude but it was also a rush job. Improvements from other macro's that I looked at is probably the fact that instead of slowly opening each bag and moving items slowly it's really freaking fast. That might be a good thing. I got a shitty PC and it worked fine for me. But please do wait until the macro says it has ended as there is only 1 check to see if the bank window and bags are open, that is at the start.
If I have time sometime in the future I'll convert this into using arrays and get it to sort the entire bank.
usage:
Must be standing at the banker with bank window open.
/mac banksorter
Better than nothing??