Page 1 of 1

Generic Buy Macro

Posted: Fri Apr 30, 2004 5:06 pm
by BrainDeath
Edit: Updated to work with new event format and handle full inventory condition

I use this to make sure I have a specified amount of an item in my inventory when tradeskilling.

For example, if you need to make sure you have 96 water flasks, you open the merchant window, select the water flask and type /macro buy 96.

Of course I have an alias set up for /buy=/macro buy.

Again, the macro does not buy the specified number, but buys until you have the specified number in your inventory.

This can easily be modifed to an include file if you wish.

Code: Select all

| buy.mac
| This macro will buy the selected item from a merchant until your
| inventory contains the specified amount of the item.
| Requires that the merchant window be open and the item selected.
| Usage: /macro buy amount

#turbo
#event Broke "#*#can't afford to buy them#*#"
#event Full "#*#no more room#*#"

Sub Main(int amount) 

    /if (!${Defined[amount]}) /endmacro

   :Buy 
      /if (${FindItemCount[=${SelectedItem}]}>=${amount}) /endmacro
      
   :StackLoop 
      /if (${Math.Calc[${amount}-${FindItemCount[=${SelectedItem}]}]}<=20) /goto :RegLoop 
      /buyitem ${If[${SelectedItem.Stackable},20,1]}
      /delay 5
      /doevents
      /goto :StackLoop 
      
   :RegLoop 
      /if (${Math.Calc[${amount}-${FindItemCount[=${SelectedItem}]}]}<=0) /endmacro
      /buyitem ${If[${SelectedItem.Stackable},${Math.Calc[${amount}-${FindItemCount[=${SelectedItem}]}]},1]}
      /delay 5
      /doevents
      /goto :RegLoop 
      
/return 

Sub Event_Broke
   /echo Error: You are out of money!
   /beep
   /endmacro
/return

Sub Event_Full
   /echo Error: Your inventory is full!
   /beep
   /endmacro
/return
Of course this is modified from someone else's macro. I don't remember who's code I used though so I can't give them credit. :(

Recommended Product Guide

Posted: Mon Oct 16, 2023 9:49 pm
by FrankJScott
Please try Google for Excellent Product Info 1b86b3c