Need help understanding script creating/editing

Gtuner IV general support. Operation, questions, updates, feature request.

Re: Need help understanding script creating/editing

Postby Mattyl22l » Wed Jul 31, 2019 11:50 am

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");
}
}
User avatar
Mattyl22l
Sergeant
Sergeant
 
Posts: 9
Joined: Fri Jul 19, 2019 11:08 am
Location: USA

Re: Need help understanding script creating/editing

Postby Scachi » Wed Jul 31, 2019 12:09 pm

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");
}
 
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 2244
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Re: Need help understanding script creating/editing

Postby Mattyl22l » Wed Jul 31, 2019 5:15 pm

Worked like a charm! Thank you! :joia:
User avatar
Mattyl22l
Sergeant
Sergeant
 
Posts: 9
Joined: Fri Jul 19, 2019 11:08 am
Location: USA

Previous

Return to Gtuner IV Support

Who is online

Users browsing this forum: No registered users and 18 guests