/Notify and Override's macros

Need help with a macro you are writing? Ask here!

Moderator: MacroQuest Developers

Curd
decaying skeleton
decaying skeleton
Posts: 4
Joined: Wed Oct 05, 2005 11:36 pm

/Notify and Override's macros

Post by Curd » Fri Oct 07, 2005 7:35 pm

http://www.macroquest2.com/wiki/index.php//notify

Hi all. I'm very new to MQ2 and have never coded before so, yes, this is most likely a stupid question but I have searched and navigated for hours on these forums without finding what I need. I'm trying to get the auto-tradeskill macros to work. I understand that with the changes to the merchant window some new code needs to be used as well as the buy.mac. Specifically,

Code: Select all

 /notify MerchantWnd MW_ItemList ${Window[MerchantWnd].Child[ItemList].List[=${Name},2]} 
and

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 
My question is how to impliment these changes within the buy.inc used in Override's macros. Here is the buy.inc:

Code: Select all

| 
| buy.inc
| Buy Include File needed for macros
| Version 1.7
| Date: September 13, 2004
|
| Please be sure to get the lastest updates at http://www.soc-music.com/mq2
|
| These file MUST be in the common directory in your macros directory.
|
| Usage: /call Buy (ItemToBuy) (Amount Needed)
|
| Use the Buy function for buying if you need a set total amount, like if you have
| 20 of the item on you already and you need a total of 30, it will only buy 10
| of the item.
|
| Usage: /call PCBuy (ItemToBuy) (Amount to buy off merchant)
|
| Use the PCBuy function if you don't need a set total amount, you just need 
| a set amount off that merchant.
|
| Disclaimer:
| Code was used from other programers also from the MQ Forums.
| 


#event Broke "#*#you cannot afford#*#" 
#event Broke "#*#you can't afford#*#" 

Sub Buy(item ItemToBuy, int amount)
/echo Buying ${ItemToBuy}!
/declare TotalMItems int Inner
/varset TotalMItems ${Merchant.Items}
/declare x int Inner
/declare ItemSlotNum int Inner
/varset ItemSlotNum 0

/for x 1 to ${TotalMItems}
  /if (${ItemToBuy.Equal[${Merchant.Item[${x}]}]}) {
    /varset ItemSlotNum ${x}
  }
/next x

/if (${ItemSlotNum}==0) {
  /echo Not on Merchant
  /return
}

/itemnotify merchant${ItemSlotNum} leftmouseup
/delay 1s


:Buy
   /if (${FindItemCount[=${SelectedItem}]}>=${amount}) {
     /echo Done!
     /return
   }        

: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) {
     /echo Done!
     /return
   }
   /buyitem ${If[${SelectedItem.Stackable},${Math.Calc[${amount}-${FindItemCount[=${SelectedItem}]}]},1]} 
   /delay 5 
   /doevents 
   /goto :RegLoop 

/return

Sub PCBuy(item ItemToBuy, int amount)
/declare TotalMItems int Inner
/varset TotalMItems ${Merchant.Items}
/declare x int Inner
/declare ItemSlotNum int Inner
/varset ItemSlotNum 0
/delay 2s

:BuyPC
   /varset ItemSlotNum 0
   /if (${amount}<=0) {
     /echo Done!
     /return
   }
   /for x 1 to ${TotalMItems}
     /if (${ItemToBuy.Equal[${Merchant.Item[${x}]}]}) {
       /varset ItemSlotNum ${x}
     }
   /next x
   /if (${ItemSlotNum}==0) {
     /echo No More on Merchant, done buying.
     /return
   }
   /itemnotify merchant${ItemSlotNum} leftmouseup
   /delay 1s
   /if (${SelectedItem.Stackable}) {
     /if (${amount}>=20) {
       /buyitem 20
       /varset amount ${Math.Calc[${amount}-20]}
     } else {
       /buyitem ${amount}
       /varset amount ${Math.Calc[${amount}-${amount}]}
     }
   } else {
     /buyitem 1
     /varset amount ${Math.Calc[${amount}-1]}
   }
   /delay 5 
   /doevents 
   /goto :BuyPC

/return

Sub Event_Broke 
   /echo Error: You are out of money! 
   /beep
   /endmacro
/return 
As I said I'm sure I should have been able to figure this out but I've een messing with it for hours and there really dosen't seem to be any comple how to for this. Thanks for the help.

DigitalMocking
a grimling bloodguard
a grimling bloodguard
Posts: 620
Joined: Mon Apr 04, 2005 5:53 pm

Post by DigitalMocking » Fri Oct 07, 2005 8:32 pm

If you search a little harder, you'll see that DKAA already posted a working buy.inc

Curd
decaying skeleton
decaying skeleton
Posts: 4
Joined: Wed Oct 05, 2005 11:36 pm

Post by Curd » Sat Oct 08, 2005 1:48 am

Are you sure you're not refering to the buy.mac of his I posted above? The question is how should it be used?

niteowlpc
orc pawn
orc pawn
Posts: 11
Joined: Tue Oct 11, 2005 7:33 am

Post by niteowlpc » Wed Oct 12, 2005 6:04 am

I have done alot of searching and all I can find that DKAA posted was a buy.mac, not a buy.inc, there is no buy.mac anywhere in overrides scripts to replace the one dkaa posted.

ebs2002
a lesser mummy
a lesser mummy
Posts: 72
Joined: Mon Apr 18, 2005 7:17 pm

Post by ebs2002 » Fri Oct 14, 2005 3:46 pm

As far as I know, DKAA did NOT post a buy.inc, just a buy.mac that is easily adaptable. This is what I use.

Code: Select all

| 
| buy.inc
| Buy Include File needed for macros
| Version 1.8 modifications by DKAA, adapted by Ebs2002
| Date: October 13, 2005
|
| These file MUST be in the common directory in your macros directory.
|
| Usage: /call Buy (ItemToBuy) (Amount Needed)
|
| The buy function will purchase (Amount Needed) copies of (ItemToBuy).  ItemToBuy 
| should be a multiple of 20, since I was lazy and haven't implimented the ability
| to purchase less than a stack at a time.  Just buy a stack of everything needed
| in the combine :-p
|
| Disclaimer:
| Code was used from other programers also from the MQ Forums.
| 


#event Broke "#*#you cannot afford#*#" 
#event Broke "#*#you can't afford#*#"
#event Room "#*#Your inventory appears full#*#"

Sub Buy(string ItemToBuy, int amount)
/echo Buying ${ItemToBuy}!
/declare l2 local int
/declare j2 local int
    /delay 1s     
    /varset l2 ${Window[MerchantWnd].Child[ItemList].List[=${ItemToBuy},2]}
    /if (!${l2}) {
        /echo couldn't find slot for ${ItemToBuy}
        /beep
        /beep
        /beep
        /endmacro
    } else {
        /notify MerchantWnd ItemList listselect ${l2}
        /delay 2
        /notify MerchantWnd ItemList leftmouse ${l2}
        /delay 4
    }

    /if (!${Window[MerchantWnd].Child[MW_SelectedItemLabel].Text.Equal[${ItemToBuy}]}) {
        /echo bad select
        /beep
        /beep
        /beep
        /endm
    }

:BuyingLoop
/if (${amount}>0) {
    /delay 5
    /shift /notify MerchantWnd MW_Buy_Button leftmouseup
    /varcalc amount ${amount}-20
    /goto :BuyingLoop
}


/return

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

Sub Event_Room
   /echo Error: You do not have any more room!
   /beep
   /endmacro
/return

xyilla
naggy
naggy
Posts: 29514
Joined: Sun Feb 23, 2025 5:36 am

Re: /Notify and Override's macros

Post by xyilla » Wed Jun 18, 2025 11:03 pm


xyilla
naggy
naggy
Posts: 29514
Joined: Sun Feb 23, 2025 5:36 am

Re: /Notify and Override's macros

Post by xyilla » Wed Jun 18, 2025 11:04 pm


xyilla
naggy
naggy
Posts: 29514
Joined: Sun Feb 23, 2025 5:36 am

Re: /Notify and Override's macros

Post by xyilla » Wed Jun 18, 2025 11:05 pm


xyilla
naggy
naggy
Posts: 29514
Joined: Sun Feb 23, 2025 5:36 am

Re: /Notify and Override's macros

Post by xyilla » Wed Jun 18, 2025 11:06 pm


xyilla
naggy
naggy
Posts: 29514
Joined: Sun Feb 23, 2025 5:36 am

Re: /Notify and Override's macros

Post by xyilla » Wed Jun 18, 2025 11:08 pm


xyilla
naggy
naggy
Posts: 29514
Joined: Sun Feb 23, 2025 5:36 am

Re: /Notify and Override's macros

Post by xyilla » Wed Jun 18, 2025 11:09 pm


xyilla
naggy
naggy
Posts: 29514
Joined: Sun Feb 23, 2025 5:36 am

Re: /Notify and Override's macros

Post by xyilla » Wed Jun 18, 2025 11:10 pm


xyilla
naggy
naggy
Posts: 29514
Joined: Sun Feb 23, 2025 5:36 am

Re: /Notify and Override's macros

Post by xyilla » Wed Jun 18, 2025 11:11 pm


xyilla
naggy
naggy
Posts: 29514
Joined: Sun Feb 23, 2025 5:36 am

Re: /Notify and Override's macros

Post by xyilla » Wed Jun 18, 2025 11:48 pm


xyilla
naggy
naggy
Posts: 29514
Joined: Sun Feb 23, 2025 5:36 am

Re: /Notify and Override's macros

Post by xyilla » Wed Jun 18, 2025 11:49 pm