Moderator: MacroQuest Developers


Code: Select all
/windowstate MerchantWnd closeCode: Select all
/windowstate MerchantWnd openCode: Select all
keypress escCode: Select all
/notify MerchantWnd MW_ItemList ${Window[MerchantWnd].Child[ItemList].List[=${Name},2]} I'll try to break down each piece for you, though I never really did a ton of manipulating windows or their children. Someone feel free to hop in anytime and point out where I'm wrong.fallenkal wrote:Aiight, so i got a command that should fix it...
now how do i use that in the script? Lol sorry but i'm a little dense when it comes to programing...Code: Select all
/notify MerchantWnd MW_ItemList ${Window[MerchantWnd].Child[ItemList].List[=${Name},2]}
PS: i know i should search and read and pour over the code and all that stuff trying to make sense of it but i just can't seem to figgure out how this stuff pieces together...
Code: Select all
/notifyCode: Select all
MerchantWndCode: Select all
MW_ItemList Code: Select all
${Window[MerchantWnd].Child[ItemList].List[=${Name},2]}With the new type of merchant lists, there are now two types of ItemList objects. ItemList for the old school square box item lists, and MW_ItemList for the newer row/column style item lists. In the new MW_ItemList objects, two fields must be referenced. So in this case, [=${name},2] means match ${name} in column 2. Column 1 is an icon, 2 is the name, 3 is the number of plat, 4 the number of gold, and so on... So, the answer to your question is Yes, it is necessary.The ${Name} portion needs to be replaced with the name of the item you're trying to select I believe, but the ,2 is where I'm confused personally. I'm not even sure that part is necessary.

Code: Select all
|
| buy.mac
| /macro buy <name>
|
sub main(string Name)
/declare l2 local int
/varset l2 ${Window[MerchantWnd].Child[ItemList].List[=${Name},2]}
/if (!${l2}) {
/echo couldn't find slot for ${Name}
/endm
} else {
/notify MerchantWnd ItemList listselect ${l2}
/delay 2
/notify MerchantWnd ItemList leftmouse ${l2}
/delay 4
}
/if (!${Window[MerchantWnd].Child[MW_SelectedItemLabel].Text.Equal[${Name}]}) {
/echo bad select
/beep
/beep
/beep
/endm
}
/delay 5
/shift /notify MerchantWnd MW_Buy_Button leftmouseup
/return
Code: Select all
/call Buy ${AShafts} 40 0
/delay 1s
/call Buy ${GrooveN} 40 0
/delay 1s
/call Buy ${CFletching} 40 0
/delay 1s
/call Buy ${AHeads} 40 1 <-- This should close the merchant window
/delay 1s
/notify MerchantWnd DoneButton leftmouseup <-- Since this will fail
Code: Select all
#event Broke "#*#can't afford to buy them#*#"
Sub Buy(item ItemToBuy, int amount, int CloseMerchant)
/echo Buying ${ItemToBuy}
/declare TotalMItems int Inner
/varset TotalMItems ${Merchant.Items}
/declare x int Inner
/declare ItemSlotNum int Inner
/varset ItemSlotNum 0
/declare ItemSlot local int
/declare ItemStacks local int
/for x 1 to ${TotalMItems}
/if (${ItemToBuy.Equal[${Merchant.Item[${x}]}]}) {
/varset ItemSlotNum ${x}
}
/next x
/if (${ItemSlotNum}==0) {
/echo Not on Merchant
/return
}
| Try to find the item in inventory. If not found buy one unit
/if (!${Window[InventoryWindow].Open}) {
/windowstate InventoryWindow open
}
/if (!${FindItem[${ItemToBuy}].InvSlot}) {
/delay 4
/varset ItemSlot ${Window[MerchantWnd].Child[ItemList].List[=${ItemToBuy},2]}
/notify MerchantWnd ItemList listselect ${ItemSlot}
/delay 2
/notify MerchantWnd ItemList leftmouse ${ItemSlot}
/delay 4
/buyitem 1
}
/delay 4
| Target the unit in inventory and get needed attributes
/call OpenPacks
/itemnotify ${FindItem[=${ItemToBuy}].InvSlot} leftmouseup
/varset ItemStacks ${SelectedItem.Stackable}
/delay 4
| Go back to the Merchant and continue as usual
/varset ItemSlot ${Window[MerchantWnd].Child[ItemList].List[=${ItemToBuy},2]}
/notify MerchantWnd ItemList listselect ${ItemSlot}
/delay 2
/notify MerchantWnd ItemList leftmouse ${ItemSlot}
/delay 4
:Buy
/if (${FindItemCount[=${ItemToBuy}]}>=${amount}) {
/goto :EndBuy
}
:StackLoop
/if (${Math.Calc[${amount}-${FindItemCount[=${ItemToBuy}]}]}<=20) /goto :RegLoop
/buyitem ${If[${ItemStacks},20,1]}
/doevents
/goto :StackLoop
:RegLoop
/if (${Math.Calc[${amount}-${FindItemCount[=${ItemToBuy}]}]}<=0) {
/goto :EndBuy
}
/buyitem ${If[${ItemStacks},${Math.Calc[${amount}-${FindItemCount[=${ItemToBuy}]}]},1]}
/doevents
/goto :RegLoop
:EndBuy
/echo Done!
/delay 2s
/if (${CloseMerchant}) {
/call CloseWindows
/delay 2s
/call OpenPacks
/delay 2s
}
/return
Sub Event_Broke
/echo Error: You are out of money!
/beep
/endmacro
/return
Sub OpenPacks
| Open all packs (stolen from packs.inc)
/declare bag int local 0
/newif (!${Window[InventoryWindow].Open}) /keypress inventory
/delay 1
/for bag 1 to 8 step 1
/newif (!${Window[pack${bag}].Open}) /itemnotify pack${bag} rightmouseup
/next bag
/delay 1
/return
| This is bad but works and I'm tired. When I find a better
| way to close the merchant window I'll implement it
Sub CloseWindows
/keypress esc
/delay 5
/keypress esc
/delay 5
/keypress esc
/delay 5
/keypress esc
/delay 5
/keypress esc
/delay 5
/keypress esc
/delay 5
/keypress esc
/delay 5
/keypress esc
/delay 5
/keypress esc
/delay 10
/return
Code: Select all
[MQ2] Please Wait........ Cleaning out Fletching Kit container
[MQ2] Done Cleaning Fletching Container. Thank you for waiting!Code: Select all
I'll give you 5 copper per Large Groove Nocks (Spammed till I end Macro)