Shortest way to code "only if" this input happens?
4 posts
• Page 1 of 1
Shortest way to code "only if" this input happens?
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!
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!
-
vietnamesepheasant - Sergeant
- Posts: 6
- Joined: Mon Oct 19, 2020 8:25 pm
Re: Shortest way to code "only if" this input happens?
Similar to this thread, you can use a while loop to check for inputs: viewtopic.php?f=6&t=16693
Example:
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
- Posts: 4532
- Joined: Wed May 22, 2019 5:39 am
Re: Shortest way to code "only if" this input happens?
Where does the <21 come from? Why 21?
-
DeviateSquirrel - First Sergeant
- Posts: 46
- Joined: Sun Jan 17, 2021 11:07 pm
Re: Shortest way to code "only if" this input happens?
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
- Posts: 4532
- Joined: Wed May 22, 2019 5:39 am
4 posts
• Page 1 of 1
Return to GPC1 Script Programming
Who is online
Users browsing this forum: No registered users and 27 guests