Track Macro Completion / Iteration - Questions
6 posts
• Page 1 of 1
Track Macro Completion / Iteration - Questions
Thanks in advance.
• What is the best way to track the completion of a macro?
• Should I place macro_run() inside a while statement to determine how many times it has run or to determine when it has completed its course?
• Does macro_run need to be in a combo to even run more than once?
• If a task comes after macro_run() in the same statement does it wait until the macro is compete before moving to the next task?
• What is the best way to track the completion of a macro?
• Should I place macro_run() inside a while statement to determine how many times it has run or to determine when it has completed its course?
- Code: Select all
if(something cool){ // will this play the macro 10 times?
uint8 i=0;
while(i<10){
macro_run(awesome_macro);
i++;
}
• Does macro_run need to be in a combo to even run more than once?
• If a task comes after macro_run() in the same statement does it wait until the macro is compete before moving to the next task?
- Code: Select all
if(something cool){ // will this play the macro then stop the combo once complete?
macro_run(awesome_macro);
combo_stop(cool_combo);
}
-
USER102 - Private First Class
- Posts: 2
- Joined: Tue Dec 11, 2018 9:13 pm
Re: Track Macro Completion / Iteration - Questions
How do you tell when a macro is complete?
-
USER101 - Sergeant Major
- Posts: 100
- Joined: Mon Dec 03, 2018 5:45 pm
Re: Track Macro Completion / Iteration - Questions
Jesscorp wrote:How do you tell when a macro is complete?
When macro_time() changes from returning values > -1 to -1
-
Scachi - Brigadier General
- Posts: 3044
- Joined: Wed May 11, 2016 6:25 am
- Location: Germany
Re: Track Macro Completion / Iteration - Questions
USER101 wrote:Thanks in advance.
• What is the best way to track the completion of a macro?
Here is one method of tracking a macro repetition.
- Code: Select all
bool toggle = TRUE;
int loop;
main {
if(toggle == TRUE){
//As long as toggle is true, the macro will loop.
macro_run("macro1.gmk");
//The macro has started when macro_time == 0.
if(macro_time() == 0) printf("loop %d", ++loop);
//after 10 loops, toggle becomes false.
if(loop==10) toggle = FALSE;
}
}
USER101 wrote:• Should I place macro_run() inside a while statement to determine how many times it has run or to determine when it has completed its course?
That's a definite a no. A while loop implemented like this, will cause your T2 to automatically timeout. While loops need to be used with caution.
USER101 wrote:• Does macro_run need to be in a combo to even run more than once?
Nope. See above example.
USER101 wrote:• If a task comes after macro_run() in the same statement does it wait until the macro is compete before moving to the next task?
No What will happen is, the macro will run, and the combo will stop. At the same time. The combo won't wait until the macro is finished before its instructed to stop.
-
Sillyasskid - Captain
- Posts: 574
- Joined: Sat May 14, 2016 3:07 am
Re: Track Macro Completion / Iteration - Questions
I used your example and alive becomes TRUE as soon example.gmk starts, is there a way to change the condition upon completion of the macro?
- Code: Select all
bool alive = FALSE;
main {
macro_run("example.gmk");
if(macro_time() == -1) { // After macro runs it should change the conditions?.
time_counter = 0;
alive = TRUE;
}
}
-
USER101 - Sergeant Major
- Posts: 100
- Joined: Mon Dec 03, 2018 5:45 pm
Re: Track Macro Completion / Iteration - Questions
Jesscorp wrote:I used your example and alive becomes TRUE as soon example.gmk starts, is there a way to change the condition upon completion of the macro?
- Code: Select all
bool alive = FALSE;
main {
macro_run("example.gmk");
if(macro_time() == -1) { // After macro runs it should change the conditions?.
time_counter = 0;
alive = TRUE;
}
}
If it can't start the macro/find the file it will also return -1
If the file is accessible your code would never set alive to TRUE as you are restarting it all this time with your macro_run command.
-
Scachi - Brigadier General
- Posts: 3044
- Joined: Wed May 11, 2016 6:25 am
- Location: Germany
6 posts
• Page 1 of 1
Return to GPC2 Script Programming
Who is online
Users browsing this forum: Baidu [Spider], midg3t2 and 189 guests