Sub Main
/echo STARTING: BuySpells - will check merchant for spells your missing and buy them.
/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 s string
/declare l2 int
/varset x 1
:loop
/varset b 0
/varset v ${Window[MerchantWnd].Child[ItemList].List[${x},2]}
| /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}]} ) {
/varset b 0
/echo ${v}
/notify MerchantWnd ItemList listselect ${x}
/delay 3
/notify MerchantWnd ItemList rightmouse ${x}
/delay 3
/echo testing popup name ${v} -> ${DisplayItem.Name}
/for i 1 to ${DisplayItem.Classes}
/varset s ${DisplayItem.Class[${i}]}
/if ( ${s.Equal[${Me.Class}]} ) /varset b 1
/next i
/if (${b}) {
/echo BUY: ${v} -> ${DisplayItem.Name} = ${DisplayItem.Class[1]}
/notify MerchantWnd ItemList leftmouse ${x}
/ctrlkey /notify MerchantWnd MW_Buy_Button leftmouseup
/delay 5
}
}
/varcalc x ${x}+1
/goto :loop
:done
/end