Multiple Macros running at once?

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

SlimFastForYou
a hill giant
a hill giant
Posts: 174
Joined: Sat Jan 24, 2004 1:38 am

Multiple Macros running at once?

Post by SlimFastForYou » Sun Feb 29, 2004 9:37 pm

Hi all,

I couldn't find an answer to this question when using the forum search so that's why I am posting...

I would like to have two different macros running at the same time. It is sort of sloppy (I know), but would it be possible?

What I would like to do is have an autopull macro running, and a timed /tell <cleric> <message> macro.

The reason I want to know is because I am trying to make an autopull macro. It is just about finished, but I am working on a way to not pull when the cleric is low on mana.

My friend's cleric is using Xylobot (he's sorta paranoid of MQ), and he does not know of a way to have her volunteer information (say "ready"). /doevents chat seems to only work properly if it is constantly being called (unless I am horribly mistaken).

The dillema is that if I ask the cleric every 30 seconds in my macro, and it takes her 5 seconds to respond, /doevents will have missed her tell, and it will repeat ad nauseum. If I have no /delay, all works except there is huge spam (which is an obvious sign to the server of macroing).

Anyway, if anyone knows, I would appreciate knowing the answer as well =). When I finish and clean up the macro (this is the last thing for me to do), I will post it =).

bob_the_builder
a hill giant
a hill giant
Posts: 275
Joined: Tue Jul 22, 2003 1:22 pm

Post by bob_the_builder » Sun Feb 29, 2004 10:09 pm

Yes and no

use an #include and the one macro can /call the other.

Code: Select all

#include autopull
#include ChatMac
#event chat

Sub Main
   :MainLoop
      /call autopull
      /doevents
   goto :MainLoop
/endmacro

Sub Event_chat
   /call ChatMac <cleric> <message>
/return
This is kinda just thrown together, but just look at #include and #event and you can make any macro, snippet into a multi macro gang bang.

After I re read... this kinda confuses me:
if I ask the cleric every 30 seconds in my macro, and it takes her 5 seconds to respond
Maybe you should post your code to review, no clue why your using a timed delay tell and totaly do idea why a 5 second delay occurs...

Bob_loves_include

SlimFastForYou
a hill giant
a hill giant
Posts: 174
Joined: Sat Jan 24, 2004 1:38 am

Post by SlimFastForYou » Tue Mar 02, 2004 5:43 am

Thanks for the tip. The code has a couple of minor bugs, and a couple of features I want to put on it before I post the whole kit-n-kaboodle. It also has some names and locs hard coded in for now. Anyway, here is the part in question:

This will not work, because /doevents is not being called constantly

Code: Select all

:MainLoop
/varset rfp 0
/tell <cleric name> rfp
/delay 30s
/doevents chat
/if @rfp==0 /goto :MainLoop
As you probably guessed, the rfp variable is changed in the chat events subroutine.

This code will work, however it will spam the hell out of the cleric

Code: Select all

:MainLoop
/varset rfp 0
/tell <cleric name> rfp
/doevents chat
/if @rfp==0 /goto :MainLoop
Hmph, it seems I answered my own question. Guess I had been writing code for too long that day, as I just could not figure it out. Sleep helps =). Then again, the tip will probably help me in some of my future work.

The solution:

Code: Select all

:MainLoop
/varset rfp 0
/tell <cleric name> rfp
:WaitForTell
/doevents chat
/if @rfp==0 /goto :WaitForTell
God, do I feel stupid. I spent way too much time trying to figure this out too. For some reason, I had it stuck in my mind that I had to use :MainLoop to keep looking for the cleric's tell.

That aside, I have another question:
#include autopull
#include ChatMac
#event chat

Sub Main
:MainLoop
/call autopull
/doevents
goto :MainLoop
/endmacro

Sub Event_chat
/call ChatMac <cleric> <message>
/return
When you do a /call autopull, wouldn't that halt execution of the current macro until autopull finishes? Otherwise, wouldn't looping /call autopull and /doevents cause rapidly spawning instances of autopull?

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

Post by Mckorr » Tue Mar 02, 2004 9:33 am

When you /call another subroutine, execution of the macro passes to that subroutine, and does not return to the call point until the sub encounters a /return.

I hope that made sense. MacroQuest scripts are linear, not multithreaded, meaning they execute one line after another. You can branch off to another set of instructions and then return to the point where you branched off, but you can't run multiple subroutines, or macros, at the same time.