Help with 360° Run script

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

Help with 360° Run script

Postby Beryl » Tue Jan 10, 2023 10:30 am

Can anyone help me with this script, i want to be able to move with the left analog with a delay before the run buttons pressed?
Currently sometimes it doent activate the run, hope this makes sense

So can someone add in a delay for AFTER left analog is moved in any direction to press the run button. Thanks
Code: Select all
main {
    if(sqrt(sq(get_actual(STICK_2_X)) + sq(get_actual(STICK_2_Y))) >= 90f) {
        combo_run(Sprint);
    }
}
 
combo Sprint {
    set_val(BUTTON_17, 100);

   
User avatar
Beryl
Sergeant Major of the Army
Sergeant Major of the Army
 
Posts: 198
Joined: Fri Nov 27, 2020 7:47 pm

Re: Help with 360° Run script

Postby Scachi » Tue Jan 10, 2023 12:13 pm

Code: Select all
#define dSprint 200 // delay before sprint
uint32 tSprint;
 
main {
    if(sqrt(sq(get_actual(STICK_2_X)) + sq(get_actual(STICK_2_Y))) >= 90f) {
        tSprint += elapsed_time();
        if (tSprint > dSprint) combo_run(cSprint);
    } else {
        tSprint = 0;
    }
}
 
combo cSprint {
    set_val(BUTTON_17, 100);
}
 
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Re: Help with 360° Run script

Postby Beryl » Tue Jan 10, 2023 12:20 pm

Thankyou! Idiot question is tSprint = 0 the bit i edit for the delay, rather ask before i mess about with it
User avatar
Beryl
Sergeant Major of the Army
Sergeant Major of the Army
 
Posts: 198
Joined: Fri Nov 27, 2020 7:47 pm

Re: Help with 360° Run script

Postby Beryl » Tue Jan 10, 2023 12:26 pm

Ignore that just see it says at top
User avatar
Beryl
Sergeant Major of the Army
Sergeant Major of the Army
 
Posts: 198
Joined: Fri Nov 27, 2020 7:47 pm

Re: Help with 360° Run script

Postby Beryl » Tue Jan 10, 2023 12:33 pm

Just tried, its perfect thanks for your help!
User avatar
Beryl
Sergeant Major of the Army
Sergeant Major of the Army
 
Posts: 198
Joined: Fri Nov 27, 2020 7:47 pm


Return to GPC2 Script Programming

Who is online

Users browsing this forum: AZOV_ops and 106 guests