Multiple Toggling?

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

Multiple Toggling?

Postby Kidd23 » Tue Sep 07, 2021 11:03 pm

I could use some help with multiple toggling.

Let's say I want to have 4 different toggles in one script, how would I do this?

For example, if I press
BUTTON9 & BUTTON15 - it would run one set of combos & turn off other toggles
BUTTON9 & BUTTON16 - it would run a different set of combos & turn off other toggles
BUTTON9 & BUTTON17 - it would run a different set of combos & turn off other toggles
BUTTON9 & BUTTON18 - it would run a different set of combos & turn off other toggles

Thanks everyone
User avatar
Kidd23
Sergeant First Class
Sergeant First Class
 
Posts: 16
Joined: Wed Dec 19, 2018 6:50 pm

Re: Multiple Toggling?

Postby Haures » Thu Sep 16, 2021 8:12 pm

Code: Select all
#pragma METAINFO("Multiple Toggles example", 1, 0, "Haures")
 
bool toggle_combo1=FALSE;
bool toggle_combo2=FALSE;
bool toggle_combo3=FALSE;
 
main {
    if (get_actual(BUTTON_9) && event_active(BUTTON_15)) {        //BUTTON_9=LS(L3) + BUTTON_15=B(Circle)
        toggle_combo1 = !toggle_combo1;
    }
    if(toggle_combo1) {
        combo_run(ComboA);
    }
    //-------------------------------------------------//
    if (get_actual(BUTTON_9) && event_active(BUTTON_16)) {        //BUTTON_9=LS(L3) + BUTTON_16=A(Cross)
        toggle_combo2 = !toggle_combo2;
    }
    if(toggle_combo2) {
        combo_run(ComboB);
    }
    //-------------------------------------------------//
    if (get_actual(BUTTON_9) && event_active(BUTTON_17)) {        //BUTTON_9=LS(L3) + BUTTON_17=X(Square)
        toggle_combo3 = !toggle_combo3;
    }
    if(toggle_combo3) {
        combo_run(ComboC);
    }
}
 
    combo ComboA {
        set_val(BUTTON_15, 0.00);
        set_val(BUTTON_16, 0.00);
        set_val(BUTTON_17, 0.00);
        wait(50);
        set_val(BUTTON_15, 0.00);
        set_val(BUTTON_16, 100.00);
        set_val(BUTTON_17, 0.00);
        wait(50);
    }
    combo ComboB {
        set_val(BUTTON_15, 0.00);
        set_val(BUTTON_16, 0.00);
        set_val(BUTTON_17, 0.00);
        wait(50);
        set_val(BUTTON_15, 0.00);
        set_val(BUTTON_16, 0.00);
        set_val(BUTTON_17, 100.00);
        wait(100);
    }
    combo ComboC {
        set_val(BUTTON_15, 0.00);
        set_val(BUTTON_16, 0.00);
        set_val(BUTTON_17, 0.00);
        wait(25);
        set_val(BUTTON_15, 0.00);
        set_val(BUTTON_16, 100.00);
        set_val(BUTTON_17, 0.00);
        wait(25);
}
 


Thats what i did in my first script and it worked (im new to programming and the Titan Two) :smile0517:

But this script does not turn off the other toggles.

Maybe somebody with more knowlegde can help there.
Haures
Sergeant First Class
Sergeant First Class
 
Posts: 16
Joined: Thu Sep 16, 2021 2:59 pm
Location: Germany

Re: Multiple Toggling?

Postby Mad » Thu Sep 16, 2021 10:27 pm

Haures wrote:But this script does not turn off the other toggles.

Maybe somebody with more knowlegde can help there.

When you activate one toggle you want to disable the others?
Code: Select all
    if (get_actual(BUTTON_9) && event_active(BUTTON_15)) {        //BUTTON_9=LS(L3) + BUTTON_15=B(Circle)
        toggle_combo1 = !toggle_combo1;
        if(toggle1_combo) {
            toggle_combo2 = FALSE;
            toggle_combo3 = FALSE;
            if(ComboB) combo_stop(ComboB);
            if(ComboC) combo_stop(ComboC);
        }
    }
ConsoleTuner Support Team || ConsoleTuner Discord || InputSense Discord (2K / FPS)
Mad
Major General
Major General
 
Posts: 4533
Joined: Wed May 22, 2019 5:39 am

Re: Multiple Toggling?

Postby Haures » Fri Sep 17, 2021 12:25 am

Mad wrote:When you activate one toggle you want to disable the others?

Kidd23 wrote:For example, if I press
BUTTON9 & BUTTON15 - it would run one set of combos & turn off other toggles
BUTTON9 & BUTTON16 - it would run a different set of combos & turn off other toggles
BUTTON9 & BUTTON17 - it would run a different set of combos & turn off other toggles
BUTTON9 & BUTTON18 - it would run a different set of combos & turn off other toggles


Thats what Kidd23 wanted i think?

Yeah thanks, i appreciate your help Mad.

(sorry for maybe bad english, im german)
Haures
Sergeant First Class
Sergeant First Class
 
Posts: 16
Joined: Thu Sep 16, 2021 2:59 pm
Location: Germany

Re: Multiple Toggling?

Postby Kidd23 » Fri Sep 17, 2021 4:27 am

That's exactly what I needed, thank you so much
User avatar
Kidd23
Sergeant First Class
Sergeant First Class
 
Posts: 16
Joined: Wed Dec 19, 2018 6:50 pm


Return to GPC2 Script Programming

Who is online

Users browsing this forum: No registered users and 75 guests