| Buyspells.mac
| 2013-09-26 Dewey2461 - Original posted
| 2016-01-17 Flatlined - Updated to remove the pop up inspects, reduce spam output, and only purchase if not already in inventory
Sub Main
/echo STARTING: BuySpells - will check merchant for spells you are missing and buy them if you don't have them in inventory already.
/if ( !${Merchant} ) {
/popup Browse merchant window and rerun
/end
}
/declare b int local
/declare x int local
/declare i int local
/declare v string
/declare o string
/declare s string
/declare l2 int
/varset x 1
:loop
/varset b 0
/varset v ${Window[MerchantWnd].Child[ItemList].List[${x},2]}
/varset o ${v}
|/echo ${v} ${v.Length} b = ${b}
/if ( !${v.Length} ) /goto :done
/if ( ${v.Mid[1,5].Equal[Song:]}) /varset b 1
/if ( ${v.Mid[1,6].Equal[Spell:]}) /varset b 1
/if ( ${v.Mid[1,7].Equal[Scroll:]}) /varset b 1
/if ( ${v.Mid[1,5].Equal[Song:]}) /varset v ${v.Mid[6,30]}
/if ( ${v.Mid[1,6].Equal[Spell:]}) /varset v ${v.Mid[7,31]}
/if ( ${v.Mid[1,7].Equal[Scroll:]}) /varset v ${v.Mid[8,32]}
/if ( ${b} && !${Me.Book[${v}]} && !${Bool[${FindItem[${o}]}]} ) {
/varset b 0
/notify MerchantWnd ItemList listselect ${x}
/delay 3
/for i 1 to ${DisplayItem.Classes}
/varset s ${DisplayItem.Classes[${i}]}
/if ( ${s.Equal[${Me.Class}]} ) /varset b 1
/next i
/varset b 1
/if (${b}) {
/if (!${Me.FreeInventory}) {
/beep
/echo INVENTORY FULL !
/echo Wanted to BUY: ${o}
/return
}
/echo BUY: ${o}
/notify MerchantWnd ItemList leftmouse ${x}
/ctrlkey /notify MerchantWnd MW_Buy_Button leftmouseup
/delay 5
}
}
/varcalc x ${x}+1
/goto :loop
:done
/end