$count(Itemname) help

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

Moderator: MacroQuest Developers

Draekz
a hill giant
a hill giant
Posts: 263
Joined: Thu Aug 01, 2002 6:07 pm
Location: Winnipeg, Manitoba, Canada

$count(Itemname) help

Post by Draekz » Sun Oct 06, 2002 12:19 am

I was wondering, is there a way to get the counter to check how many of a specific item are in your inventory, and if the item amount isnt == to what you want it to be, it buys the specific amount for you?

Lets say you want it to check if you have 200 of the item (10 stacks). For some reason you had 3 left over in your inventory, when it goes to buy the items again it checks and sees that you have 3 so only buys 9 stacks and 17 of the last stack.

Now what i want to know, is there any simpler way of doing this other than /else /if loops? I think that would take WAY too much space to get it to count it and if it doesnt equal this, /call buyitem, etc etc.

IE:

Code: Select all

/if n $count("Large Block of Clay")==200 {
   /goto :SkipClay
   }else /if n $count("Large Block of Clay")!=200 {

   /get $count("Large Block of Clay")  (and fill the difference)

Ok i dunno if there is a get command but nonetheless i hope that clarifies what i mean? I've read through the manual countless times and cant seem to think of anyway to do this (that wouldnt require 200 /if /else loops)

Thanks for the help!

Draekz

User avatar
ap50
a snow griffon
a snow griffon
Posts: 425
Joined: Sun Aug 18, 2002 2:29 pm

Post by ap50 » Mon Oct 07, 2002 6:05 am

I just cheat and sell what stock of the items I have left back to the vendor before re-stocking up.

I suppose if the items were for Jewel craft, I'd handle it differently, but as my trade-skill macros are purely for skill ups, and not for finance, I usually go with the cheap components, so it doesn't matter.
[color=yellow][size=92][b]Just because you're paranoid, it doesn't mean everyone isn't out to get you![/b][/size][/color]

Valerian
a grimling bloodguard
a grimling bloodguard
Posts: 709
Joined: Sun Jul 28, 2002 3:29 am

Post by Valerian » Mon Oct 07, 2002 6:31 am

maybe something like...

Code: Select all

| Select the item you're buying from the merchant before this point...
/sendkey down ctrl
:MakeEvenStacks
|   This /if checks to see if you have a number of "Large Block of Clay"
| evenly divisible by 20. If not, it will buy one at a time until it gets 
| that full stack.
/if n $calc($count("Large Block of Clay")%20)==0 /goto :StacksAreEven
   /if n $freeinv(space)==0 /goto :NoMoreSpace
   /click left merchant buy
   /goto :MakeEvenStacks
:StacksAreEven
/sendkey up ctrl
/sendkey down shift
:Fullstacks
|   Here, we check to see if we have the proper number of stacks,
| and if not, buy full stacks one at a time until we have the required
| number of items.
/if n $count("Large Block of Clay")==200 /goto :Donebuying
   /if n $freeinv(space)==0 /goto :NoMoreSpace
   /click left merchant buy
   /goto :Fullstacks
:NoMoreSpace
/echo Your inventory is full! Stopped buying with $count("Large Block of Clay") items.
:Donebuying
/sendkey up ctrl
/sendkey up shift
|  Voila! You now have 10 even stacks of your "Large Block of Clay"
That should do it... untested, but it should work.

Note: I honestly don't think that "Large Block of Clay" is stackable, but I could be wrong.

Also note: If this is run with #turbo, be sure to include some delays

Draekz
a hill giant
a hill giant
Posts: 263
Joined: Thu Aug 01, 2002 6:07 pm
Location: Winnipeg, Manitoba, Canada

Post by Draekz » Mon Oct 07, 2002 12:23 pm

Well fortunately i figured it out ;) took me over 7 hours of coding to get a proficient working set of code...basically if you have specific amount up to a nother specific amount..it'll buy stacks of that until the last stack and then buy singles until u reach said amount..

Unfortunately it also works too well and therefore i dont think i can/should release the code as my scripts never bomb now because it always adds up correctly and even on lagging it doesnt crash because it has a "backup" measure..

Take it ez all

Isnt that hard to figure out if you look tho ;)

Draekz

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

Post by Fippy » Mon Oct 07, 2002 12:40 pm

Lol 7 hours of coding man thats dedication. You could have earnt XXX pp smurf hut building in that time that would more then compensate for a few lost plat selling stuff back to the vendor. Of course if it was for the challenge of getting it to work then I fully understand.

Fippy

Note I censored myself before posting hehe.

Valerian
a grimling bloodguard
a grimling bloodguard
Posts: 709
Joined: Sun Jul 28, 2002 3:29 am

Post by Valerian » Mon Oct 07, 2002 12:55 pm

7 hours?? I coded that little snippet of code up there in like 5 minutes in the message editor right here... sheesh. 7 hours. */boggle*

Draekz
a hill giant
a hill giant
Posts: 263
Joined: Thu Aug 01, 2002 6:07 pm
Location: Winnipeg, Manitoba, Canada

Post by Draekz » Mon Oct 07, 2002 4:17 pm

LOL actually it was primarily because i was dedicated to get a working script hehehe

And just so ya know..i know NOTHING about coding lol im doing it all from scratch ;) But all the same..its working!!! Using something a friend called "recursive" coding or something like that..hah..

All the same im loving it ;) Still seems to hang once every 1k or so but i have no idea why..ummm i'll show u the code i worked so hard on lol..i dont mind giving it away hehe...well i do cuz its my precious precious sleeping hours spent trying to figure this stuff out..ehh..i just dont want anyone using it..it'll ruin the glory of it all heheh..

(and the sad part is..when i look at it now..its SOOO simple...its just the learning process that took so many hours hah..and debugging of course) hehe

Anyway if fipp or val (or anyone else i recognize from IRC) or you 4 or 5 stars want it (and u can even criticize it! lol i dont mind) just post a pm or not on this thread..hehe

You'll laugh when u realize how basic it is :P

But all the same im proud of myself for doing that from basically no programming skill whatsoever (well vb in grade 11 but that was like 5 yrs ago) heheh

Draekz