[ isearch.mac ] Vendor Search Macro

A forum for you to dump all the macros you create, allowing users to use, modify, and comment on your work.

Moderator: MacroQuest Developers

User avatar
lostcarrier
decaying skeleton
decaying skeleton
Posts: 9
Joined: Wed Feb 25, 2004 7:05 pm

[ isearch.mac ] Vendor Search Macro

Post by lostcarrier » Wed Feb 25, 2004 7:11 pm

This is a little macro that I wrote to farm tradeskill items from vendors. Instructions are in the code.

Version 1.2 Changes
:: added the ability to update the INI file on the fly using the /echo command (greets to ml2517 for the inadvertant INI tutorial)
:: removed some extraneous code

Version 1.1 Changes
:: added code to differentiate between stackable and non-stackable items
:: changed inventory full check to something cleaner

Code: Select all

|=-=-=-=-=-=-=-=-= ISEARCH.MAC :: MERCHANT SEARCH MACRO =-=-=-=-=-=-=-=-=
|
| To Start: /mac isearch
| To Add or Remove an item from the INI File: /echo update ItemName
|     Example: "/echo update Puppy Feet" adds Puppy Feet to the INI file
|              if it is not there, or removes it if it already exists.
|
| To Reload INI File: /echo reload
|
| Usage:   Add items that you want to buy in bulk from a merchant 
|          to the INI file.  Run the macro.  It will wait until you 
|          open a merchant window to begin searching.  The macro 
|          will cycle through all of your specified items, purchasing
|          EVERY one that the merchant has.  
|
| Example: If you have Wolf Meat specified in your INI file, and the 
|          merchant has 182 Wolf Meats for sale, you will buy all of 
|          them until either his supply is exhausted or you run out 
|          of money.
|
| Info:    Once the macro has cycled through all of the items in your
|          INI file, it will close the merchant window and wait for
|          another merchant window to open, whereupon it will begin 
|          its search anew.  If you wish, the INI file can be edited
|          while the macro is running, and reloaded by simply /echo-ing
|          "reload" into the MQ2 window.  Running out of money, or having
|          a full inventory will cause the macro to end.
|
| INI File Syntax
|
|  [Items]
|  0=Wolf Meat
|  1=Snake Egg
|  2=Mammoth Meat
|  3=Centi Toes
|  ..and so on
|
|=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=


#event NOMONEY "but you can't afford to buy them."
#event FULLBAGS "You have no more room."
#event RELOAD "[MQ2] reload"
#event UPDATE "[MQ2] update"

Sub Main

   /zapvars
   
   /declare ItemArraySize global
   /declare Temp0 global
   /declare ItemArray array
   
   /call LoadItems
   
   /echo Waiting for a merchant.
   
   :MainLoop
     /doevents
     /if $merchant(open)==TRUE /call ItemCheck
     /goto :MainLoop
/return

Sub ItemCheck
 /for Temp0 0 to @ItemArraySize
   /if "@ItemArray(@Temp0)"=="Empty" {
     /if @Temp0==@ItemArraySize {
       /echo Search complete.  Waiting for next merchant.
       /click left button merchant_done
       /return
     }
   /next Temp0
   }
     :MerchantCheck
      /if $freeinv(space)==0 {
       /echo Your inventory is full.  Exiting.
       /endmacro
      }       
       /echo Searching for [ @ItemArray(@Temp0) ]
       /if $merchant(has,"@ItemArray(@Temp0)")==FALSE {
         /if @Temp0==@ItemArraySize {
          /echo Search complete.  Waiting for next merchant.
          /click left button merchant_done
          /return
         }
         /next Temp0
       }
       /selectitem "@ItemArray(@Temp0)" merchant
       /if "$selecteditem(count)"=="NOT_STACKABLE" {
        /buyitem 1
        /goto :MerchantCheck
       }
       /delay 2s
       /buyitem 20
       /delay 2s
       /goto :MerchantCheck
   /next Temp0
/return

Sub Event_NOMONEY
 /echo You are out of money.
 /endmacro
/return

Sub Event_FULLBAGS
 /echo Your inventory is full.
 /endmacro
/return

Sub Event_RELOAD
 /echo Reloading Items from INI file.
 /call LoadItems
 /echo Items reloaded.  Waiting for a merchant.
/return

Sub LoadItems 
 /declare Temp1 local 
 /declare TempList local 
 /declare Empties local
 /varset Empties 0
 /varset Temp1 0 

 :ClearList 
  /varset TempList "$ini("isearch.ini","Items","$int(@Temp1)")"
   /if "@TempList"=="NOTFOUND" /goto :ClearComplete 
   /varset ItemArray(@Temp1) "Empty" 
   /varadd Temp1 1 
 /goto :ClearList 
 
 :ClearComplete 
   /varset Temp1 0 
   :LoadList 
     /varset ItemArray(@Temp1) "$ini("isearch.ini","Items","$int(@Temp1)")" 
     /if "@ItemArray(@Temp1)"=="NOTFOUND" {
     /varset ItemArraySize $int(@Temp1)
     /varsub ItemArraySize 1
     /varset ItemArraySize $int(@ItemArraySize)
      /return 
     }
     /varadd Temp1 1 
   /goto :LoadList 

/return 

Sub Event_UPDATE(EvtText)
/declare TempItem local
/declare Temp2 local
/declare Temp3 local
/varset Temp2 0
/varset EvtText "$mid(13,$calc($strlen("@EvtText")-13),"@EvtText")"

/if "@EvtText"!="" {
    :ItemSearch
     /varset TempItem "$ini("isearch.ini","Items","$int(@Temp2)")"
     /if "@TempItem"=="NOTFOUND" /goto :AddItem
     /if "@TempItem"=="@EvtText" {
        /echo [ @EvtText ] Deleted from INI file.
        /ini "isearch.ini" "Items" "$int(@Temp2)" "Empty"
        /goto :DoneItem
     }
    /varadd Temp2 1
    /goto :ItemSearch

    :AddItem
     /varset Temp2 0
     :AddItemLoop
      /varset TempItem "$ini("isearch.ini","Items","$int(@Temp2)")"
      /if "@TempItem"=="Empty" /goto :FoundItemSlot   
      /if "@TempItem"=="NOTFOUND" /goto :FoundItemSlot
      /varadd Temp2 1
     /goto :AddItemLoop

    :FoundItemSlot
     /echo [ @EvtText ] Added to INI file.
     /ini "isearch.ini" "Items" "$int(@Temp2)" "@EvtText"
} else {
    /varset Temp3 0
    /echo =-= Current Items =-=
    :ItemList
    /varset TempItem "$ini("isearch.ini","Items","$int(@Temp2)")"
    /if "@TempItem"=="NOTFOUND" /goto :DoneItemList
    /varadd Temp2 1
    /if "@TempItem"!="Empty" {
        /varadd Temp3 1
        /echo Item $int(@Temp3) [ @TempItem ]
    }
    /goto :ItemList

    :DoneItemList
    /if n @Temp3==0 /echo No Items found.

}
:DoneItem
/call LoadItems
/return 
Last edited by lostcarrier on Thu Feb 26, 2004 1:44 pm, edited 3 times in total.
CARRIER LOST
No connection.

endymion
a lesser mummy
a lesser mummy
Posts: 34
Joined: Sat Feb 21, 2004 8:37 pm

Post by endymion » Thu Feb 26, 2004 3:26 am

this is a GODSEND....REALLY helps when searching POK vendors for enchanter research pages. Thanks a lot!

User avatar
lostcarrier
decaying skeleton
decaying skeleton
Posts: 9
Joined: Wed Feb 25, 2004 7:05 pm

Post by lostcarrier » Thu Feb 26, 2004 7:09 am

Thanks, Endymion; I'm glad someone found a use for it.

The original post has been updated with version 1.1.
CARRIER LOST
No connection.

User avatar
lostcarrier
decaying skeleton
decaying skeleton
Posts: 9
Joined: Wed Feb 25, 2004 7:05 pm

Post by lostcarrier » Thu Feb 26, 2004 1:43 pm

1.2 Posted. Probably the final revision unless I find a big issue.
CARRIER LOST
No connection.

DJPrez
a lesser mummy
a lesser mummy
Posts: 46
Joined: Fri Feb 07, 2003 11:34 pm

Post by DJPrez » Sun Mar 07, 2004 11:30 pm

This is the first macro I have ever tried,,,,actually my first time using MQ2,,,, anyways ---- it loads up fine,, I even added a water flask to the ini by using the /echo command and it updated the ini (so, it said).

Then off to a merchant I went to try it out.... As soon as I right clicked on the merchant I get the "You have been disconnected" screen and proceed directly to desktop.

Guess MQ2 is not for nOObs. =(

User avatar
lostcarrier
decaying skeleton
decaying skeleton
Posts: 9
Joined: Wed Feb 25, 2004 7:05 pm

Post by lostcarrier » Mon Mar 08, 2004 2:50 pm

I just tried it, starting with no INI file, added Water Flask, clicked on a merchant with no Water, it worked fine. Clicked on a merchant that had water for sale, it happilly started buying stacks of water flasks.

I'm at a loss as to what your problem might be. :(
CARRIER LOST
No connection.

DJPrez
a lesser mummy
a lesser mummy
Posts: 46
Joined: Fri Feb 07, 2003 11:34 pm

Post by DJPrez » Mon Mar 08, 2004 3:26 pm

It's more than likely me,,,,, I have been having issues with MQ2 since I installed it -- I continue to CTD =((( This was just the very first thing I tried ,,,,,sorry. I hope to get it working !

GD
a snow griffon
a snow griffon
Posts: 353
Joined: Sat Jun 29, 2002 11:57 pm

Post by GD » Mon Mar 08, 2004 9:43 pm

If you have a problem with it not buying stuff when you know the vendor has it, it's because the list of items isn't fully sent before the $merchant(open) returns a TRUE value, since it's only saying the window is open, not that it's populated. It's most noticeable if you have a slow or laggy connection.

To fix this, add a small delay after the /doevents in :MainLoop like so:

Code: Select all

   :MainLoop
     /doevents
     [color=red]/delay 5[/color]
     /if $merchant(open)==TRUE /call ItemCheck
     /goto :MainLoop
You may need to increase it till it works for your particular connection.
Opinions are like assholes, everyone has one, but most of them stink.

cronic
a grimling bloodguard
a grimling bloodguard
Posts: 536
Joined: Wed Nov 26, 2003 11:01 pm

Post by cronic » Tue Mar 09, 2004 2:49 pm

I don't have EQ where I am right now, so I can't check, but doesn't the merchant say "Welcome to my shop" or whatever AFTER the list is populated? If that's the case, you could just use an event for that, and then check for your items after that fires.