Shortest way to code "only if" this input happens?

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

Shortest way to code "only if" this input happens?

Postby vietnamesepheasant » Sun Nov 01, 2020 3:43 am

I'd like to run a combo if the left stick is held right, but only if NO OTHER buttons/inputs are registered. I ostensibly could write:

if(get_val(SWITCH_LX)==100 && get_val(SWITCH_X)==0 && get_val(SWITCH_Y)==0....

etc. etc. until I write down every single input. Is there a simpler way to code "if this value is 100 AND every other input is 0, then run combo"?

Thank you!
User avatar
vietnamesepheasant
Sergeant
Sergeant
 
Posts: 6
Joined: Mon Oct 19, 2020 8:25 pm

Re: Shortest way to code "only if" this input happens?

Postby Mad » Sun Nov 01, 2020 7:54 pm

Similar to this thread, you can use a while loop to check for inputs: viewtopic.php?f=6&t=16693
Example:
Code: Select all
int i; 
int input;
main {
    if(get_val(SWITCH_LX) > 90) {
        i = 0;
        while(i < 21) {
            if(event_press(i)) {
                input = 1;
                break;
            }
            i++;
        }
        if(!input) combo_run(Loop);
    }
    else input = 0;
}
 
combo Loop {
    set_val(XB1_A, 100);
    wait(50);
    set_val(XB1_A, 0);
    wait(50);
}
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: Shortest way to code "only if" this input happens?

Postby DeviateSquirrel » Sun Jan 31, 2021 6:58 pm

Where does the <21 come from? Why 21?
User avatar
DeviateSquirrel
First Sergeant
First Sergeant
 
Posts: 46
Joined: Sun Jan 17, 2021 11:07 pm

Re: Shortest way to code "only if" this input happens?

Postby Mad » Sun Jan 31, 2021 9:36 pm

DeviateSquirrel wrote:Where does the <21 come from? Why 21?

The button array index, how many inputs to block.
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 27 guests