Start and stop with same button??

GPC1 script programming for Titan One. Code examples, questions, requests.

Start and stop with same button??

Postby Ctuna2000 » Sat Jul 31, 2021 9:40 pm

So, this is how far I've gotten.

Code: Select all
main {
 
  if (event_press(XB1_LEFT)) {  // Press LEFT to begin combo
    combo_run(combo1)
  }
  if (get_val(XB1_DOWN)) {      // Press DOWN to stop combo
    if(combo_running(combo1) && event_press(XB1_DOWN)){
      combo_stop(combo1);
    }
  }
}
 
combo combo1 {


How can I start and stop the script with the same button? (Start and stop with XBOX_DOWN)


Thanks.
User avatar
Ctuna2000
Sergeant Major
Sergeant Major
 
Posts: 84
Joined: Tue Mar 09, 2021 10:09 pm

Re: Start and stop with same button??

Postby Mad » Sat Jul 31, 2021 10:50 pm

Try this:
Code: Select all
main {
    if(event_press(XB1_LEFT)) {  // Press LEFT to begin combo
        if(combo_running(combo1)) combo_stop(combo1);
        else combo_run(combo1)
    }
}
combo combo1 {
 
}
ConsoleTuner Support Team || ConsoleTuner Discord || InputSense Discord (2K / FPS)
Mad
Major General
Major General
 
Posts: 4532
Joined: Wed May 22, 2019 5:39 am

Re: Start and stop with same button??

Postby Ctuna2000 » Sun Aug 01, 2021 12:01 am

Mad wrote:Try this:
Code: Select all
main {
    if(event_press(XB1_LEFT)) {  // Press LEFT to begin combo
        if(combo_running(combo1)) combo_stop(combo1);
        else combo_run(combo1)
    }
}
combo combo1 {
 
}


Hi, thanks! Looks great!

Also, I'm not sure if there's any need of a "stop". From what I can see this kind of script only does the script once, then stops?

My other combos ("mycombo"), repeat the script over and over.


Any ideas?

Thanks.
User avatar
Ctuna2000
Sergeant Major
Sergeant Major
 
Posts: 84
Joined: Tue Mar 09, 2021 10:09 pm

Re: Start and stop with same button??

Postby Mad » Sun Aug 01, 2021 12:09 am

You can do it like this so it runs in a loop until you press left again.
Code: Select all
int toggle;
main {
    if(event_press(XB1_LEFT)) {  // Press LEFT to begin combo
        toggle = !toggle;
    }
    if(toggle) combo_run(combo1)
    else if(combo_running(combo1)) combo_stop(combo1);
}
combo combo1 {
 
}
ConsoleTuner Support Team || ConsoleTuner Discord || InputSense Discord (2K / FPS)
Mad
Major General
Major General
 
Posts: 4532
Joined: Wed May 22, 2019 5:39 am


Return to GPC1 Script Programming

Who is online

Users browsing this forum: No registered users and 58 guests