stuck on a condition

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

stuck on a condition

Postby alencroat » Wed Jun 24, 2020 12:21 am

Hey Im stuck on double tap hold condition, but the same button is to macro rapid so something like this: but not working
Code: Select all
#pragma METAINFO("MW ALEN", 1, 0, "<co-op>")
 
 
#define X_BUTTON        BUTTON_17
 
 
 
 
main {
 
//RAPID X
 
    if(get_val(X_BUTTON) && time_release(X_BUTTON) < 300 && time_active(X_BUTTON) > 500) {
        combo_run(RAPIDx);
    }
}
 
combo RAPIDx {
    set_val(X_BUTTON, 100.0);
    wait(40);
    set_val(X_BUTTON, 0.0);
    wait(40);
}
 
 
 
 

I'M looking for x button to do this: if normally pressed to have normal function, but if i double tap and hold x to run combo RAPIDx, and to keep running it as long as Im holding x button. Is there any chance to write this code in with out switched or switches is a must.

EDIT: So I did some digging and I found this
Code: Select all
bool toggle;
 
main {
    if(event_active(BUTTON_16) && time_release(BUTTON_16) <= 200) {
        toggle = 1;
    }else if(event_release(BUTTON_16)) {
        toggle = 0;
    }
    if(toggle == 1) {
        combo_run(TEST);
    }
}   
combo TEST
{
    set_val(BUTTON_16, 100.0);
    wait(40);
    set_val(BUTTON_16, 0.0);
    wait(40);
 
}


any chance to make it work with out a switch, just wondering
User avatar
alencroat
Lieutenant
Lieutenant
 
Posts: 320
Joined: Sun Oct 15, 2017 5:58 pm

Re: stuck on a condition

Postby Scachi » Wed Jun 24, 2020 6:26 am

The last one is already only active as long as you hold down that button after the double tap.
As soon as you release that button the combo will not be started anymore.
Not sure what you are asking for.
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Re: stuck on a condition

Postby bonefisher » Wed Jun 24, 2020 7:27 am

Code: Select all
bool toggle;
 
main {
    if(event_active(BUTTON_17) && time_release(BUTTON_17) <= 200) {
        toggle = 1;
    }else if(event_release(BUTTON_17)) {
        toggle = 0;
    }
    if(toggle == 1) {
        combo_run(RAPIDx);
    }
}
combo RAPIDx {
    set_val(BUTTON_17, 100.0);
    wait(40);
    set_val(BUTTON_17, 0.0);
    wait(40);
}
 

No way around it unless you wanted just run once the combo!

Now I don't see why I couldn't do it I built one that should of but only ran once when it should of loop until I release !
bonefisher
Lieutenant General
Lieutenant General
 
Posts: 5413
Joined: Thu Jan 29, 2015 10:49 am

Re: stuck on a condition

Postby Buffy » Thu Jun 25, 2020 12:07 am

Without having to use a toggle var:

Code: Select all
main {
    rapid_cross = (rapid_cross || ((event_active(BUTTON_16) && time_release(BUTTON_16) <= 200))) * is_active(BUTTON_16);
}
 
combo rapid_cross {
    set_val(BUTTON_16, 100.0);
    wait(40);
    set_val(BUTTON_16, 0.0);
    wait(40);
    combo_restart(rapid_cross);
    wait(0);
}
 
ConsoleTuner Support Team || Discord || Custom Scripts
User avatar
Buffy
Lieutenant
Lieutenant
 
Posts: 422
Joined: Wed Jul 20, 2016 5:23 am

Re: stuck on a condition

Postby DontAtMe » Thu Jun 25, 2020 2:50 am

Buffy wrote:Without having to use a toggle var:
Without having to use a combo

Code: Select all
bool toggle;
main {
  if(is_active(BUTTON_16)) {
    if(event_active(BUTTON_16))
      if(time_release(BUTTON_16) < 200)
        ++toggle;
    if(toggle) set_val(BUTTON_16, ((system_time()%80) < 40));
  }
  else toggle = 0;
}
User avatar
DontAtMe
Captain
Captain
 
Posts: 502
Joined: Tue Oct 02, 2018 4:49 am

Re: stuck on a condition

Postby alencroat » Sun Jul 05, 2020 6:56 pm

thanks guys! :smile0202:
User avatar
alencroat
Lieutenant
Lieutenant
 
Posts: 320
Joined: Sun Oct 15, 2017 5:58 pm


Return to GPC2 Script Programming

Who is online

Users browsing this forum: No registered users and 137 guests