Page 2 of 2

Re: Need help understanding script creating/editing

PostPosted: Wed Jul 31, 2019 11:50 am
by Mattyl22l
Hey guys having a problem...trying to get my macro to run endlessly.

How do I make it so that if "button 9" is pressed once it will initiate the macro forever? So I don't have to keep hitting or holding the button.

I just used the example from the resources. :)


main {
// While BUTTON_2 is held-down ...
if(get_val(BUTTON_9)) {
// ... keep the macro "Example" running in an endless loop.
macro_run("wolf.gmk");
}
}

Re: Need help understanding script creating/editing

PostPosted: Wed Jul 31, 2019 12:09 pm
by Scachi
Use a variable to set it to play or stop on button press.

This should do:
Code: Select all
bool play=FALSE;
 
main {
// The very moment the button gets pressed
        if (event_active(BUTTON_9)) {
            play=!play; // inverse the current state
            if (!play) macro_stop(); // remove the // at the start of the line stop the playback instantly when play gets disabled
        }
 
        // ... keep the macro "Example" running in an endless loop.
        if (play) macro_run("wolf.gmk");
}
 

Re: Need help understanding script creating/editing

PostPosted: Wed Jul 31, 2019 5:15 pm
by Mattyl22l
Worked like a charm! Thank you! :joia: