Page 1 of 1

Can I restart my macro from within the macro?

Posted: Sat Sep 10, 2016 11:41 pm
by RabbitKing
Or, is there a way to call a macro without it getting hosed up by skipping imports?

Thanks so much!

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

Posted: Sun Sep 11, 2016 6:31 am
by warlock45
could set up a sub to reset variables to default values I suppose... is that what you are after?

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

Posted: Sun Sep 11, 2016 9:09 am
by dewey2461
I have a few macros which call each other and one that calls itself to restart so it can be done.

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

Posted: Sun Sep 11, 2016 8:20 pm
by JudgeD
I also have macros setup with vars that will tell it to reset when it's appropriate to do so.

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

Posted: Mon Sep 12, 2016 6:23 pm
by RabbitKing
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!

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

Posted: Mon Sep 12, 2016 9:31 pm
by warlock45
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.

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

Posted: Tue Sep 13, 2016 2:28 am
by LamahHerder
What are you trying to do? Probably a better way we can suggest if we knew

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

Posted: Fri Oct 14, 2016 1:06 am
by RabbitKing
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.

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

Posted: Sat Oct 15, 2016 2:43 am
by moguay
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.

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

Posted: Wed Nov 23, 2016 8:24 am
by Voland
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.

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

Posted: Wed Dec 07, 2016 5:20 am
by Voland
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.

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

Posted: Wed Dec 07, 2016 7:03 am
by JudgeD
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.

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

Posted: Wed Dec 07, 2016 12:32 pm
by warlock45
Is the macro really called /bigmacro.mac ? Or is that slash there for a reason ?

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