if condition not working
11 posts
• Page 1 of 2 • 1, 2
if condition not working
This is my script:
I wanted the combo to run once so I swapped is_active to event_active for BUTTON_5 (worked), BUT the second condtion (BUTTON_9) is not being taken into account. The script should work like this:
BUTTON_8 (HOLD) + BUTTON_9 (just press, that's why I'm using release) + BUTTON_5 (press) (run combo once).
It should only work if those conditions are met, but somehow if I press BUTTON_8 + BUTTON_5 it still runs the combo (and BUTTON_9 is not being taken into consideration).
Help is appreciated.
EDIT: I fond the error after some time, it's actually executing the combo because the is_release statement is TRUE because the BUTTON_9 is INDEED released, but how would I make it so it only works if I press BUTTON_9 then release and then the rest of the condition?
It should somehow be something like this:
- Code: Select all
main {
if(is_active(BUTTON_8) && is_release(BUTTON_9) && event_active(BUTTON_5)) {
combo_run(cLeanLeft);
}
}
combo cLeanLeft {
set_val(BUTTON_6, 100.00);
wait(110);
set_val(BUTTON_9, 100.00);
wait(110);
}
I wanted the combo to run once so I swapped is_active to event_active for BUTTON_5 (worked), BUT the second condtion (BUTTON_9) is not being taken into account. The script should work like this:
BUTTON_8 (HOLD) + BUTTON_9 (just press, that's why I'm using release) + BUTTON_5 (press) (run combo once).
It should only work if those conditions are met, but somehow if I press BUTTON_8 + BUTTON_5 it still runs the combo (and BUTTON_9 is not being taken into consideration).
Help is appreciated.
EDIT: I fond the error after some time, it's actually executing the combo because the is_release statement is TRUE because the BUTTON_9 is INDEED released, but how would I make it so it only works if I press BUTTON_9 then release and then the rest of the condition?
It should somehow be something like this:
- Code: Select all
main {
if(is_active(BUTTON_8) && event_active(BUTTON_9) && event_release(BUTTON_9)&& event_active(BUTTON_5)) {
combo_run(cLeanLeft);
}
}
-
Derivates - Sergeant Major
- Posts: 75
- Joined: Sat Jan 19, 2019 6:15 pm
Re: if condition not working
Instead of event_release(BUTTON_9) use time_release(BUTTON_9) < 200, also it's pretty much impossible for 2 buttons to trigger event_active at the same time.
- Code: Select all
main {
if(is_active(BUTTON_8) && (check_active(BUTTON_9, 200) && time_release(BUTTON_9) < 200) && event_active(BUTTON_5)) {
combo_run(cLeanLeft);
}
}
-
Buffy - Lieutenant
- Posts: 422
- Joined: Wed Jul 20, 2016 5:23 am
Re: if condition not working
Buffy wrote:Instead of event_release(BUTTON_9) use time_release(BUTTON_9) < 200, also it's pretty much impossible for 2 buttons to trigger event_active at the same time.
- Code: Select all
main {
if(is_active(BUTTON_8) && (check_active(BUTTON_9, 200) && time_release(BUTTON_9) < 200) && event_active(BUTTON_5)) {
combo_run(cLeanLeft);
}
}
Tried it, but it's no completing the if statement, the combo isn't running at all; the conditions are never met.
-
Derivates - Sergeant Major
- Posts: 75
- Joined: Sat Jan 19, 2019 6:15 pm
Re: if condition not working
Sorry, try this instead:
- Code: Select all
#include <XB1.gph>
main {
if(is_active(XB1_LT) && is_active(XB1_LS) && time_release(XB1_LS) < 400 && event_active(XB1_RT)) {
combo_run(cLeanLeft);
}
}
-
Buffy - Lieutenant
- Posts: 422
- Joined: Wed Jul 20, 2016 5:23 am
Re: if condition not working
Buffy wrote:Sorry, try this instead:
- Code: Select all
#include <XB1.gph>
main {
if(is_active(XB1_LT) && is_active(XB1_LS) && time_release(XB1_LS) < 400 && event_active(XB1_RT)) {
combo_run(cLeanLeft);
}
}
Sorry for the late reply I've been very busy, the script still doesn't do anything, I'm trying with all the possible ways to execute this, but no action. @J2KBr maybe???
-
Derivates - Sergeant Major
- Posts: 75
- Joined: Sat Jan 19, 2019 6:15 pm
Re: if condition not working
I guess I'm not fully understanding this part where you phrase it
"BUTTON_8 (HOLD) + BUTTON_9 (just press, that's why I'm using release) + BUTTON_5 (press) (run combo once)."
The conditions are:
button 8 held + button 9 activated within the last 200 ms (and is still held?) + button 5 just activated? If so, the code would be
"BUTTON_8 (HOLD) + BUTTON_9 (just press, that's why I'm using release) + BUTTON_5 (press) (run combo once)."
The conditions are:
button 8 held + button 9 activated within the last 200 ms (and is still held?) + button 5 just activated? If so, the code would be
- Code: Select all
main {
if(is_active(BUTTON_8) && (is_active(BUTTON_9) && time_active(BUTTON_9) < 200) && event_active(BUTTON_5)) {
combo_run(cLeanLeft);
}
}
combo cLeanLeft {
set_val(BUTTON_6, 100.00);
wait(110);
set_val(BUTTON_9, 100.00);
wait(110);
}
-
Buffy - Lieutenant
- Posts: 422
- Joined: Wed Jul 20, 2016 5:23 am
Re: if condition not working
- Code: Select all
main {
if(is_active(BUTTON_8)){
if(is_active(BUTTON_9) && event_active(BUTTON_5)) {
combo_run(cLeanLeft);
}
}
}
combo cLeanLeft {
set_val(BUTTON_6, 100.00);
wait(110);
set_val(BUTTON_9, 100.00);
wait(110);
}
- bonefisher
- Lieutenant General
- Posts: 5413
- Joined: Thu Jan 29, 2015 10:49 am
Re: if condition not working
maybe this ?
Edit: Actually I think I understand what the OP is asking for.
I had to read thru the previous posts a couple more times, I am pretty sure this is what he's trying to do
@Derivates give this last script a try.
- Code: Select all
main {
if(is_active(BUTTON_8)){
if(event_active(BUTTON_5)){
cLeanLeft = is_active(BUTTON_9);
cLeanRight = is_active(BUTTON_6);
}
}
}
combo cLeanLeft {
wait(110);
set_val(BUTTON_6, 100);
set_val(BUTTON_9, 0);
wait(110);
}
combo cLeanRight {
wait(110);
set_val(BUTTON_9, 100);
set_val(BUTTON_6, 0);
wait(110);
}
Edit: Actually I think I understand what the OP is asking for.
I had to read thru the previous posts a couple more times, I am pretty sure this is what he's trying to do
@Derivates give this last script a try.
- Code: Select all
main {
uint32 timer;
//---
if(is_active(BUTTON_8)){
timer+=elapsed_time();
if(event_active(BUTTON_6) || event_active(BUTTON_9)) timer = 0;
if(event_active(BUTTON_5) && (is_release(BUTTON_6) && is_release(BUTTON_9))){
cLeanLeft = !check_release(BUTTON_9, timer);
cLeanRight = !check_release(BUTTON_6, timer);
}
} else timer = 0;
//---
}
combo cLeanLeft {
set_val(BUTTON_6, 100);
wait(110);
set_val(BUTTON_9, 100);
wait(110);
}
combo cLeanRight {
set_val(BUTTON_9, 100);
wait(110);
set_val(BUTTON_6, 100);
wait(110);
}
-
DontAtMe - Captain
- Posts: 502
- Joined: Tue Oct 02, 2018 4:49 am
Re: if condition not working
Buffy wrote:I guess I'm not fully understanding this part where you phrase it
"BUTTON_8 (HOLD) + BUTTON_9 (just press, that's why I'm using release) + BUTTON_5 (press) (run combo once)."
The conditions are:
button 8 held + button 9 activated within the last 200 ms (and is still held?) + button 5 just activated? If so, the code would be
- Code: Select all
main {
if(is_active(BUTTON_8) && (is_active(BUTTON_9) && time_active(BUTTON_9) < 200) && event_active(BUTTON_5)) {
combo_run(cLeanLeft);
}
}
combo cLeanLeft {
set_val(BUTTON_6, 100.00);
wait(110);
set_val(BUTTON_9, 100.00);
wait(110);
}
Didn't work, but last response did. Thanks for your help and pardon the late response.
-
Derivates - Sergeant Major
- Posts: 75
- Joined: Sat Jan 19, 2019 6:15 pm
Re: if condition not working
bonefisher wrote:
- Code: Select all
main {
if(is_active(BUTTON_8)){
if(is_active(BUTTON_9) && event_active(BUTTON_5)) {
combo_run(cLeanLeft);
}
}
}
combo cLeanLeft {
set_val(BUTTON_6, 100.00);
wait(110);
set_val(BUTTON_9, 100.00);
wait(110);
}
Didn't work, but last response did. Thanks for your help and pardon the late response.
-
Derivates - Sergeant Major
- Posts: 75
- Joined: Sat Jan 19, 2019 6:15 pm
11 posts
• Page 1 of 2 • 1, 2
Return to GPC2 Script Programming
Who is online
Users browsing this forum: midg3t2 and 76 guests