Can someone make this script loop automatically? (Toggle)
7 posts
• Page 1 of 1
Can someone make this script loop automatically? (Toggle)
The macro file is on a Micro SD, running perfectly as is. I just want it to toggle on and off loop with the button press instead of having to tap it every time.
- Code: Select all
main {
if(event_active(BUTTON_13)) { // Run the Macro once.
macro_run("Reset.gmk");
}
}
-
LegendHimself - Private First Class
- Posts: 3
- Joined: Sat Jan 26, 2019 10:07 am
Re: Can someone make this script loop automatically? (Toggle
- Code: Select all
bool Toggle=FALSE;
main {
if(event_active(BUTTON_13)) Toggle=!Toggle;
if (Toggle) macro_run("Reset.gmk");
}
-
Scachi - Brigadier General
- Posts: 3044
- Joined: Wed May 11, 2016 6:25 am
- Location: Germany
Re: Can someone make this script loop automatically? (Toggle
Thanks, I appreciate it. Is there a way to set a wait timer so it loops every x amount of seconds?
-
LegendHimself - Private First Class
- Posts: 3
- Joined: Sat Jan 26, 2019 10:07 am
Re: Can someone make this script loop automatically? (Toggle
LegendHimself wrote:Thanks, I appreciate it. Is there a way to set a wait timer so it loops every x amount of seconds?
This will do:
- Code: Select all
bool Toggle;
int32 timer;
main {
if(event_active(BUTTON_13)) {
Toggle = !Toggle;
timer = 0;
}
if(Toggle && macro_time() < 0) {
if(timer > 0) {
timer -= elapsed_time();
} else {
macro_run("Reset.gmk");
timer = 5000; // Time to wait
}
}
}
ConsoleTuner Support Team
-
J2Kbr - General of the Army
- Posts: 20323
- Joined: Tue Mar 18, 2014 1:39 pm
Re: Can someone make this script loop automatically? (Toggle
Thanks for your help as well J2Kbr
-
LegendHimself - Private First Class
- Posts: 3
- Joined: Sat Jan 26, 2019 10:07 am
Re: Can someone make this script loop automatically? (Toggle
I'm very interested in this, thank you for sharing and everyone who participated.
How would you go about looping the macro a set amount of TIMES instead of using a timer.
Thank you
How would you go about looping the macro a set amount of TIMES instead of using a timer.
Thank you
-
rivox1 - Staff Sergeant
- Posts: 15
- Joined: Sun Sep 03, 2017 6:07 pm
Re: Can someone make this script loop automatically? (Toggle
rivox1 wrote:How would you go about looping the macro a set amount of TIMES instead of using a timer.
Example of how execute the macro a certain amount of TIMES:
- Code: Select all
#define TIMES 5
bool Toggle;
int32 counter;
main {
if(event_active(BUTTON_13)) {
Toggle = !Toggle;
counter = 0;
}
if(Toggle && macro_time() < 0) {
if(counter < TIMES) {
macro_run("Reset.gmk");
counter++;
}
}
}
ConsoleTuner Support Team
-
J2Kbr - General of the Army
- Posts: 20323
- Joined: Tue Mar 18, 2014 1:39 pm
7 posts
• Page 1 of 1
Return to GPC2 Script Programming
Who is online
Users browsing this forum: No registered users and 142 guests