Rapid Fire Toggle Support

Main forum, anything related to ConsoleTuner world.

Rapid Fire Toggle Support

Postby Lifty » Thu Sep 12, 2019 5:14 pm

Hello All. I am trying to create a toggle key (Button_20) so that I can toggle on and off my rapid fire combo.
I am a new titan 2 user and have a very basic understanding of scripting. I would also like an LED indictor so I know if the rapid fire is on or off. Right now my rapid fire works fine but I need to hold down Button_20 for the rapid fire to stop. I anyone could help me create a toggle button (that doesn't need to be pressed while firing) with LED indicator I would appreciate it. Thank you :)

Code: Select all
 
 
main {
    if(get_val(BUTTON_5)) {
        combo_run(Rapidfire);
    }
        if(get_val(BUTTON_20)) {
        combo_stop(Rapidfire);
}
}   
combo Rapidfire {
    set_val(BUTTON_5, 100);
    wait(12);
    set_val(BUTTON_5, 0);
    wait(12);
    set_val(BUTTON_5, 0);
}
 
 
User avatar
Lifty
Corporal
Corporal
 
Posts: 4
Joined: Tue Aug 13, 2019 12:23 am

Re: Rapid Fire Toggle Support

Postby Mad » Fri Sep 13, 2019 12:16 am

Code: Select all
#define RF_HOLD    33
#define RF_RELEASE 64
 
bool rapidfire;
 
init {
  led(255,0,0);
}   
 
main {
  if (event_active(19)) {
    rapidfire = !rapidfire;
    if(rapidfire) led(0,255,0);
    else led(255,0,0);
  }
 
  if(rapidfire && get_actual(4)) combo_run(RapidFire);
}
 
void led(int8 r, int8 g, int8 b) {
  led_set(LED_1, (fix32)b, 0);
  led_set(LED_2, (fix32)r, 0);
  led_set(LED_3, (fix32)g, 0);
  return;
}
 
combo RapidFire {
  set_val(4, 100);
  wait(RF_HOLD);
  set_val(4, 0);
  wait(RF_RELEASE);
}
ConsoleTuner Support Team || Discord
Mad
Captain
Captain
 
Posts: 482
Joined: Wed May 22, 2019 5:39 am

Re: Rapid Fire Toggle Support

Postby Lifty » Fri Sep 13, 2019 5:31 pm

Thank you for the reply Mad.The scripts works beautifully! I appreciate you getting back to me!
User avatar
Lifty
Corporal
Corporal
 
Posts: 4
Joined: Tue Aug 13, 2019 12:23 am

Re: Rapid Fire Toggle Support

Postby Mad » Fri Sep 13, 2019 11:38 pm

You're welcome
ConsoleTuner Support Team || Discord
Mad
Captain
Captain
 
Posts: 482
Joined: Wed May 22, 2019 5:39 am


Return to General Support

Who is online

Users browsing this forum: No registered users and 11 guests