wanting to learn how to write macros

Need some help with that macro you're working on or aren't quite sure how to get your macro to do something? Ask here!

Moderator: MacroQuest Developers

MacroN00b
decaying skeleton
decaying skeleton
Posts: 8
Joined: Tue Oct 07, 2003 2:06 pm

wanting to learn how to write macros

Post by MacroN00b » Tue Oct 07, 2003 2:17 pm

Hi all,

I want to learn how to write macros, I have fought a bit with the online help and such but I cant creat a working macro with it..

if anyone could write a small macro (forexcample to make celestial essence which I have been trying to do) that would be awesome.

If possible add short comments to each line saying what is been done here.

looking forward to make my own awesome macros and share em with you

thanx alot for the help
The N00b

Mckorr
Developer
Developer
Posts: 2326
Joined: Fri Oct 18, 2002 1:16 pm
Location: Texas

Post by Mckorr » Tue Oct 07, 2003 2:27 pm

Your best bet is to take a look in the Macro Depot and study existing scripts. Granted they should be commented more, but there are some nice easy ones in there that can help you learn.

The various help and readme files are all being updated after a massive language change. Hopefully they'll be available soon.
MQ2: Think of it as Evolution in action.

MacroN00b
decaying skeleton
decaying skeleton
Posts: 8
Joined: Tue Oct 07, 2003 2:06 pm

Post by MacroN00b » Tue Oct 07, 2003 2:30 pm

ok for now maybe, can somoene tell me..

if I want to combine something in a brew barrel I use

/finditem "Cask"
/if $find()==FALSE /goto :Done
/click left enviro 8

/click left enviro combine


now how would it have to look if I wanted to put it into a mortar and pestil in the last bagslot of my inventory for excample?

thats the only thing I dont get atm rest seems pretty clear after I looked through some of the existing macros

Mckorr
Developer
Developer
Posts: 2326
Joined: Fri Oct 18, 2002 1:16 pm
Location: Texas

Post by Mckorr » Tue Oct 07, 2003 2:36 pm

If you are using a combiner in one of your inventory slots you call it just like a backpack. Assuming your mortar and pestle is in your last inventory slot:

/click right inv 7 ----> That opens the pack
/finditem "chewing gum" -----> picks up the item you want to combine
/click left pack 7 0 -------> places your chewing gum in slot 0 of the open combiner
/click left pack 7 combine -----> hits the combine button, making a sticky mess
MQ2: Think of it as Evolution in action.

Scrime
a ghoul
a ghoul
Posts: 86
Joined: Sun Sep 21, 2003 5:48 pm
Contact:

Post by Scrime » Tue Oct 07, 2003 2:40 pm

Code: Select all

Sub Main
  /declare vTSCombiner global

  | try to find the trade skill combiner
  /call FindCombiner "Mortar and Pestle"
  /if n @vTSCombiner==99 {
    /echo "Could not find trade skill container, exiting."
    /endmacro keep keys
  }

  | open the container we just found
  /click right inv @vTSCombiner
/return

Sub FindCombiner 
  /declare vTemp local

  /varset vTSCombiner 99
  /for @vTemp 0 to 7 
    /if "$pack(@vTemp,name)"=="@Param0" /varset vTSCombiner @vTemp 
  /next @vTemp 
/return
This should get you started, it will look at your inventory and open the "Mortar and Pestle" container. You should be able to figure it out, the documentation that comes with MQ is not so old that its useless.

MacroN00b
decaying skeleton
decaying skeleton
Posts: 8
Joined: Tue Oct 07, 2003 2:06 pm

Post by MacroN00b » Tue Oct 07, 2003 2:47 pm

wow thats great Scrime, thanx alot..

I didnt say the documentaion is useless, I said I cant get my macro to work with it.. but your post fixed my problem...

peace and thanx

Mckorr
Developer
Developer
Posts: 2326
Joined: Fri Oct 18, 2002 1:16 pm
Location: Texas

Post by Mckorr » Tue Oct 07, 2003 2:54 pm

Code: Select all

/declare vTSCombiner global 
ewww, Hungarian notation :)
MQ2: Think of it as Evolution in action.

Scrime
a ghoul
a ghoul
Posts: 86
Joined: Sun Sep 21, 2003 5:48 pm
Contact:

Post by Scrime » Tue Oct 07, 2003 3:03 pm

*looks innocent* :oops:

MacroN00b
decaying skeleton
decaying skeleton
Posts: 8
Joined: Tue Oct 07, 2003 2:06 pm

Post by MacroN00b » Tue Oct 07, 2003 3:39 pm

Code: Select all

#turbo
Sub Main
   :CelEss
   /sendkey down ctrl

      /finditem "Celestial Solvent"
      /if $find()==FALSE /goto :Done
      /click left pack 7 0

      /finditem "The Scent of Marr"
      /if $find()==FALSE /goto :Done
      /click left pack 7 1

      /sendkey up ctrl
      /click left pack 7 combine

      :WaitCombine
      /if "$cursor()"!="TRUE" /goto :WaitCombine

      /click left auto 
      /goto :CelEss

   :Done
    /sendkey up ctrl
    /click left pack 7 done
/return
ok thats what I came up with by now.. I decided not to look for the container to combine it in cus I will open it b4 starting macro..

now sometimes after putting the 2 comps into the mortar it goes click combine but then nothing happens, the 2 ingredients are still in the mortar and wont combine.. then I hit combine myself then macro runs again till it waits for combine again..

whats wrong there? I have been looking at the hero brew macro and it looks same like mine on that part but it works

thanx alot

MacroFiend
a grimling bloodguard
a grimling bloodguard
Posts: 662
Joined: Mon Jul 28, 2003 2:47 am

Post by MacroFiend » Tue Oct 07, 2003 3:52 pm

The problem you are seeing is that MQ is running faster than EQ. So it had just put the last component in the container and moved the mouse but EQ lost the click.

Throw a few delays in there after click commands and you should be ok. (You might want a /delay after your /finditem also since it results in a click)

Scrime
a ghoul
a ghoul
Posts: 86
Joined: Sun Sep 21, 2003 5:48 pm
Contact:

Post by Scrime » Tue Oct 07, 2003 3:52 pm

I have had that problem as well, not sure what the cause is.

It might help to add a /delay 1 after the /click left pack 7 combine, or it might help to add the delay before the combine.

You could also write a more elaborate routine to check to see if the combiner still has stuff in it, and if so hit the combine button again... kinda like:

Code: Select all

.
.
.
:HitCombine
  | hit the combine button on our combiner
  /click left pack 7 combine
  | wait just a fraction of a second
  /delay 1
  | if there is still an item in the combiner, the combine didn't  work
  | and we should try hitting the combine button again.
  /if "$item(7,0,name)"!="" /goto :HitCombine
.
.
.
You may have to play with the string matching, as I am not 100% what $item returns when there is no item there, and I can't test it while I am at work.

Mckorr
Developer
Developer
Posts: 2326
Joined: Fri Oct 18, 2002 1:16 pm
Location: Texas

Post by Mckorr » Tue Oct 07, 2003 4:02 pm

/delay 2 after the click is usually the minimum. Or loop a cursor check in there to make sure it is recognized. Covered in another post somewhere.
MQ2: Think of it as Evolution in action.

Plazmic
The One
The One
Posts: 800
Joined: Fri Jun 14, 2002 12:31 am
Contact:

Post by Plazmic » Tue Oct 07, 2003 10:59 pm

Don't forget, you can only combine once a second... dang VI
- Plazmic

Mckorr
Developer
Developer
Posts: 2326
Joined: Fri Oct 18, 2002 1:16 pm
Location: Texas

Post by Mckorr » Wed Oct 08, 2003 10:24 am

Yeah, I usually put a /delay 1s after /click combine to cover that mandatory delay.
MQ2: Think of it as Evolution in action.

Jaerin
Developer
Developer
Posts: 133
Joined: Mon Mar 10, 2003 7:37 pm
Contact:

Post by Jaerin » Wed Oct 08, 2003 2:22 pm

Here is what I used to use...

Code: Select all

Sub ItemOnCursor
                /declare OnCursorTimer timer
	/varset OnCursorTimer 7
	:ItemOnWait
	/if $cursor()==TRUE /goto :ItemOn
	/delay 0
	/if n @OnCursorTimer==0 {
		/click left
		/varset OnCursorTimer 7
		/goto :ItemOnWait
	}
	/goto :ItemOnWait
	:ItemOn
	/delay 1
/return

Code: Select all

Sub ItemNotOnCursor
                /declare NotOnCursorTimer timer
	/varset NotOnCursorTimer 7
	:ItemNotOnWait
	/if $cursor()==NULL /goto :ItemNotOn
	/delay 0
	/if n @NotOnCursorTimer==0 {
		/click left
		/varset NotOnCursorTimer 7
		/goto :ItemNotOnWait
	}
	/goto :ItemNotOnWait
	:ItemNotOn
	/delay 1
/return

This is usually what I use for any checking of items on or off the cursor. Usually in any of my tradeskill macros. I call this after any transaction that should put an item on or off the cursor.

**I converted it to the new format on the fly so it might be wrong**

Jaerin