Macro help

GPC2 script programming for Titan Two. Code examples, questions, requests.

Macro help

Postby teckx » Sat Jul 04, 2020 2:21 pm

Hello all.

I am trying to tweak this so i can control it a bit easier. Id like the ability to break the macro from running its entirety if i need to.

also wanted to require the dpad left and dpad right be held down for a second before the macro runs

im unsure if this would work but my idea would be : hold down dpad left or dpad right for a second which toggles a bool !on
if !on run macro

if half way through the macro i need it to stop can i simply toggle the bool to !off to have it stop the macro?


Code: Select all
 
main {
 
    if (event_active(BUTTON_12)) macro_run("macrp5A.gmk");
    if (event_active(BUTTON_13)) macro_run("macrp6A.gmk");
}
User avatar
teckx
Sergeant Major of the Army
Sergeant Major of the Army
 
Posts: 194
Joined: Tue Mar 27, 2018 1:53 pm

Re: Macro help

Postby Scachi » Sat Jul 04, 2020 4:20 pm

use check_active(button,time) to check if a button is pressed for that time set or longer, you can start the macro directly from there. you have to stop the macro with macro_stop() , without a file name.
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Re: Macro help

Postby teckx » Sat Jul 04, 2020 4:34 pm

Scachi wrote:use check_active(button,time) to check if a button is pressed for that time set or longer, you can start the macro directly from there. you have to stop the macro with macro_stop() , without a file name.



Thanks again for all the help! This works perfectly

Code: Select all
main {
 
    if (check_active(BUTTON_12,1000)) macro_run("macrp5A.gmk");
    if (check_active(BUTTON_13,1000)) macro_run("macrp6A.gmk");
    if (check_active(BUTTON_9,500)) macro_stop();
}
 
User avatar
teckx
Sergeant Major of the Army
Sergeant Major of the Army
 
Posts: 194
Joined: Tue Mar 27, 2018 1:53 pm


Return to GPC2 Script Programming

Who is online

Users browsing this forum: No registered users and 101 guests