if condition not working

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

Re: if condition not working

Postby Derivates » Thu Apr 18, 2019 4:53 pm

DontAtMe wrote:maybe this ? :unsure:
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);
}

The second attempt worked perfectly, thanks a lot.
User avatar
Derivates
Sergeant Major
Sergeant Major
 
Posts: 75
Joined: Sat Jan 19, 2019 6:15 pm

Previous

Return to GPC2 Script Programming

Who is online

Users browsing this forum: No registered users and 66 guests