Can I restart my macro from within the macro?

Need help running MacroQuest2? Ask your questions about how to get things to work on your computer.

Moderator: MacroQuest Developers

RabbitKing
Custom Builder
Custom Builder
Posts: 13
Joined: Mon May 05, 2008 7:53 am

Can I restart my macro from within the macro?

Post by RabbitKing » Sat Sep 10, 2016 11:41 pm

Or, is there a way to call a macro without it getting hosed up by skipping imports?

Thanks so much!

User avatar
warlock45
a grimling bloodguard
a grimling bloodguard
Posts: 881
Joined: Sat Oct 06, 2007 8:32 pm

Re: Can I restart my macro from within the macro?

Post by warlock45 » Sun Sep 11, 2016 6:31 am

could set up a sub to reset variables to default values I suppose... is that what you are after?

dewey2461
Contributing Member
Contributing Member
Posts: 1759
Joined: Sun Apr 17, 2005 1:53 am

Re: Can I restart my macro from within the macro?

Post by dewey2461 » Sun Sep 11, 2016 9:09 am

I have a few macros which call each other and one that calls itself to restart so it can be done.

JudgeD
a snow griffon
a snow griffon
Posts: 354
Joined: Sat Aug 18, 2012 8:07 pm

Re: Can I restart my macro from within the macro?

Post by JudgeD » Sun Sep 11, 2016 8:20 pm

I also have macros setup with vars that will tell it to reset when it's appropriate to do so.

RabbitKing
Custom Builder
Custom Builder
Posts: 13
Joined: Mon May 05, 2008 7:53 am

Re: Can I restart my macro from within the macro?

Post by RabbitKing » Mon Sep 12, 2016 6:23 pm

Trying these approaches (other the re-initialization one) didn't work out for me.

Writing a proper re-initialize subroutine would be the correct way to go, but I hacked it with /keypress

Thanks for the suggestions!

User avatar
warlock45
a grimling bloodguard
a grimling bloodguard
Posts: 881
Joined: Sat Oct 06, 2007 8:32 pm

Re: Can I restart my macro from within the macro?

Post by warlock45 » Mon Sep 12, 2016 9:31 pm

The macro I am familiar with has a "newzone" event that re initializes specific variables with in the macro.

I have also seen macros that call for a second macro, which does a small function, then that calls the first macro, resetting variables that way.

LamahHerder
a hill giant
a hill giant
Posts: 299
Joined: Sat Jun 29, 2002 2:37 am

Re: Can I restart my macro from within the macro?

Post by LamahHerder » Tue Sep 13, 2016 2:28 am

What are you trying to do? Probably a better way we can suggest if we knew

RabbitKing
Custom Builder
Custom Builder
Posts: 13
Joined: Mon May 05, 2008 7:53 am

Re: Can I restart my macro from within the macro?

Post by RabbitKing » Fri Oct 14, 2016 1:06 am

I sorted it out. I have a ton of variables which have a default state set in their declaration. These get changed based on a number of events, and I wanted to create a lazy way of resetting to default values.

I made an initialization method which sets them; now I can simply reset them at any time. Problem solved. I was just being lazy.

moguay
decaying skeleton
decaying skeleton
Posts: 6
Joined: Sat Apr 24, 2010 6:39 am

Re: Can I restart my macro from within the macro?

Post by moguay » Sat Oct 15, 2016 2:43 am

To effect a hot restart for different needs, in particular to perform some debugging/coding.

I created a primary start.mac script for init plugin, global variables/timer, alias, UI, key bind... and reinit global timer after EQ restart
then at the end, I auto launch my hand macro main.mac with this function

Code: Select all

Sub StartMain
    | Show MQ2 Error on Start sequence
    /if (${MacroQuest.Error.NotEqual[NULL]}) {
        /bcaa //docommand /${echo} ${Cr}Last MQ2 error${Cx}: ${MacroQuest.Error} - [ PC:${Ct}${Me.CleanName}${Cx} ]
    }
    /squelch /docommand /macro main.mac
/return
so with an alias /restart /bcaa //macro main.mac we can make quick and hot restarts.

Voland
orc pawn
orc pawn
Posts: 29
Joined: Mon Jul 18, 2005 3:33 am

Re: Can I restart my macro from within the macro?

Post by Voland » Wed Nov 23, 2016 8:24 am

How do you properly start a 2nd macro from the first macro?

I have a simple macro (no includes, no variables) that I would like to use to start a 2nd big macro (uses many .inc files, globals/locals, many subs).

Code: Select all

Sub Main
/echo Started Simple Mac
/docommand /macro bigmacro.mac
/echo Ending Simple Mac

/return
In MQ2 window I get
Started Simple Mac
The current macro has ended
The current macro has ended
but no error messages nothing.

http://macroquest2.com/includes/wassup/manual.php does not mention anything just says:
/macro filename [ Param0 [ Param1...]]
Starts running a macro. Calling a macro from another macro will end the calling macro.
So it makes sense that Ending Simple Mac is not seen.

What is not clear why bigmacro is ending immediately.

I can start bigmacro normally from MQ2 window with /mac bigmacro

So starting a second macro from the first macro loses something compared to starting it from MQ2 window.

Voland
orc pawn
orc pawn
Posts: 29
Joined: Mon Jul 18, 2005 3:33 am

Re: Can I restart my macro from within the macro?

Post by Voland » Wed Dec 07, 2016 5:20 am

I figured a workaround to restarting a macro within a macro.

Instead of having

Code: Select all

/docommand /macro /bigmacro.mac
in my simple.mac

I put in

Code: Select all

/keypress =
Where = goes to EQ shortcut which has /mac bigmacro.mac

This works perfectly, that is simple macro gets stopped and bigmacro starts.

Why EQ shortcut would work but in macro command would not I am unsure.

JudgeD
a snow griffon
a snow griffon
Posts: 354
Joined: Sat Aug 18, 2012 8:07 pm

Re: Can I restart my macro from within the macro?

Post by JudgeD » Wed Dec 07, 2016 7:03 am

Voland wrote:

Code: Select all

/docommand /macro /bigmacro.mac
This should have been:

Code: Select all

/macro /bigmacro.mac
docommand wasn't needed, so it failed.

User avatar
warlock45
a grimling bloodguard
a grimling bloodguard
Posts: 881
Joined: Sat Oct 06, 2007 8:32 pm

Re: Can I restart my macro from within the macro?

Post by warlock45 » Wed Dec 07, 2016 12:32 pm

Is the macro really called /bigmacro.mac ? Or is that slash there for a reason ?

Shouldn't it be just "/macro bigmacro"?