Sub BuyItem

Help section from before the user variable changes that broke all macros

Moderator: MacroQuest Developers

banananose
orc pawn
orc pawn
Posts: 27
Joined: Sun Sep 01, 2002 8:13 am

Sub BuyItem

Post by banananose » Wed Oct 30, 2002 10:50 am

I'm having a problem with Sub BuyItem. I've got the specific problem pinpointed, and have tried a few different work arounds, but have not achieved satisfactory results. The problem involves this line:

Code: Select all

/varcalc v98 $char(gold)*100+$char(silver)*10+$char(copper)
One of the items I am purchasing in my macro comes to an even platinum amount when bought in a stack of 20 - no gold, silver, copper. Therefore, when it calcs the cash before and after /click left merchant buy, the amount is the same, and it stays stuck in the loop. I've tried adding $char(plat)*1000 to the calculation, and I get a cannot parse Sub BuyItem error, and EQ locks up. I thought maybe it was too large a figure, so I tried using just $char(plat)*10+$char(gold). I got the same cannot parse error, but it doesn't lock - in fact it behaves normally, but it spams my screen with the error every time I buy or sell anything. So for now, I'm using Sub BuyItem for the other components, and a simple /click left merchant buy in the normal loop (not in a sub) for that particular item, with a /delay 1 after the buy. The problem is, it doesn't want to let me buy more than 1 stack that way. No matter how many clicks I put in, it buys one stack only. So my macro is running smoothly since I've taken everything down to 1 stack. I'd like to do more combines between merchant interaction, though. I need help modifying sub buyitem to account for platinum, or buying multiple stacks without the help of that subroutine.

Thanks for reading through, and for any insights.

-BN

User avatar
Madman
a ghoul
a ghoul
Posts: 144
Joined: Wed Jun 26, 2002 4:16 pm

Post by Madman » Wed Oct 30, 2002 12:45 pm

have you tried just removing the money calculations portion of the macro so it dont log it ??? I know it is a nice feature but the simplier the macro the less chance of errors.

banananose
orc pawn
orc pawn
Posts: 27
Joined: Sun Sep 01, 2002 8:13 am

Post by banananose » Wed Oct 30, 2002 12:56 pm

It's not a money logging feature. It checks the amount of coin you have, buys the item selected before calling the subroutine, then checks the amount of coin you have. It has a loop that will return from the sub if your coin amount has changed. If your coin amount has not changed, it will wait in that loop until it does - this way, the macro knows the buy has completed, before returning to the main.

Repard
orc pawn
orc pawn
Posts: 23
Joined: Sun Oct 20, 2002 8:12 pm

Post by Repard » Wed Oct 30, 2002 1:24 pm

I have no idea if this will work but how about something like this /

Code: Select all

/varcalc v98 $char(plat)*100+$char(gold)*10+$char(silver)+$char(copper)/10
Instead of using 1000 for plat use the 100 and shift them all down a tenth. Like I said I don't know if this will work cause I'm at work but I have seen something like this in other macros. I guess it's worth a try. I'll get around to trying it when I get home today. Let me know if it works.

banananose
orc pawn
orc pawn
Posts: 27
Joined: Sun Sep 01, 2002 8:13 am

Post by banananose » Thu Oct 31, 2002 3:12 am

I went with exactly that, but I just dropped off the copper from the calc. Works like a champ. I really have no idea why I was getting parse errors before. Thanks for the help =)

-BN

User avatar
Fippy
a snow griffon
a snow griffon
Posts: 499
Joined: Tue Jul 16, 2002 10:42 am

Post by Fippy » Thu Oct 31, 2002 5:58 am

$char(cash) returns the amount you have in cp. If you buy something this will go down so I reckon it would make the sub simplers as there are les calcs to do.

Ill have a look at sub buyitem and see.

Fippy.

User avatar
Fippy
a snow griffon
a snow griffon
Posts: 499
Joined: Tue Jul 16, 2002 10:42 am

Post by Fippy » Thu Oct 31, 2002 6:01 am

Actually i just looked in sub buyitem in routines.mac at it does use $char(cash) already.

Do you have an old one ?

Fippy

banananose
orc pawn
orc pawn
Posts: 27
Joined: Sun Sep 01, 2002 8:13 am

Post by banananose » Thu Oct 31, 2002 8:20 am

Cool, Fippy, thanks - I'll hafta try that out. I didn't take my Sub Buyitem from the routines, it was sitting there in tact from the original macro I was using and modified for something new. Less calcs is better!

-BN