notaplayer
Member
- Joined
- Jan 2, 2017
- RedCents
- 69¢
I'm new to macro writing, but not "completely" new to coding. Can you call a macro within a subroutine, preferably for a specified period of time, then end it?
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
if you have a macro start another macro, the first macro would end and the new one beginI'm new to macro writing, but not "completely" new to coding. Can you call a macro within a subroutine, preferably for a specified period of time, then end it?
if you did /timed 60 /mac newmacro it would end the macro that is running by default. you would need to put /end after that to to end the current macro so the new one didn't try to start while the old one was still running.As sic said, if I did the /timed 60 /mac newmacro, it would end the called macro after 60 seconds/minutes, but also discontinue the original macro also. Correct?
/mac somemacname
when you already have a macro running, the macro that is running will end. However, unless it's been corrected since I last checked, calling a macro from another macro will cause the new macro to skip the first line of the second macro. In which if the first line is to create a variable, check a parameter, etc it wouldn't do that action. Typically I just added a /squelch /echo first line could be skipped if this is called from another macro
|MacroOne
Sub Main
/declare something string local MacroOne
/echo ${something}
/mac MacroTwo
/return
|MacroTwo
Sub Main
/declare somethingelse string local MacroTwo
/echo ${somethingelse}
/mac MacroOne
/return
#warning
to the top of the macros.) then will call back MacroOne, which would subsequently also repeat the same unexpected behavior.|MacroOne
Sub Main
/squelch /echo first line could be skipped if this is called from another macro
/declare something string local MacroOne
/echo ${something}
/mac MacroTwo
/return
|MacroTwo
Sub Main
/squelch /echo first line could be skipped if this is called from another macro
/declare somethingelse string local MacroTwo
/echo ${somethingelse}
/mac MacroOne
/return
/squelch
/timed ## /mac MacroTwo
where the number symbols represent the amount of time in 10ths of a second you want to wait prior to executing the command. But this is a rather inefficient manner of accomplishing this task. 6 seconds is a rather long time to wait for something else to happen. So by combining the two macros you would simply just call the starting function of the second macro and the transition would be seamless, you avoid bypassing any glitches created by using a method of calling a macro from another macro.|TheOnlyMacro
Sub Main
/while (1) {
/declare something string local MacroOne
/echo ${something}
/call StepTwo
|This delay is needed for a while loop. 1/10th of a second is really short so this macro will definitely spam your MQ2 Chat window rather quickly.
/delay 1
}
/return
Sub StepTwo
/declare somethingelse string local MacroTwo
/echo ${somethingelse}
/return