What data type is BUTTON_1 and can i turn it into variable?

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

What data type is BUTTON_1 and can i turn it into variable?

Postby neit720 » Sun Sep 15, 2019 8:59 am

I'm trying to make a script that check for what button is pressed then choose it to activate whenever certain combination of buttons is used. So i want to use BUTTON_X as a variable instead of #DEFINE it. Something like this.

Code: Select all
datatype ActivatedBTN = BUTTON_1
main {
    if(get_val(BUTTON_5) > 99.9){
        if(is_active(BUTTON_10)){
            set_val(BUTTON_10, 0.0);
            if(is_active(BUTTON_16)){
                ActivatedBTN = BUTTON_16
            }
            if(is_active(BUTTON_17)){
                ActivatedBTN = BUTTON_17
            }
        }
        else if(is_active(BUTTON_11)){
            set_val(BUTTON_11, 0.0);
            set_val(ActivatedBTN, 100.0);
        }
    }
}


If it is not possible is there any other way?
User avatar
neit720
Master Sergeant
Master Sergeant
 
Posts: 26
Joined: Sun Oct 21, 2018 10:25 am

Re: What data type is BUTTON_1 and can i turn it into variab

Postby J2Kbr » Sun Sep 15, 2019 9:03 am

Yes, you can use variables to check the inputs. The data type should be uint8.
Code: Select all
uint8 ActivatedBTN = BUTTON_1;
 
main {
    if(get_val(BUTTON_5) > 99.9){
        if(is_active(BUTTON_10)){
            set_val(BUTTON_10, 0.0);
            if(is_active(BUTTON_16)){
                ActivatedBTN = BUTTON_16;
            }
            if(is_active(BUTTON_17)){
                ActivatedBTN = BUTTON_17;
            }
        }
        else if(is_active(BUTTON_11)){
            set_val(BUTTON_11, 0.0);
            set_val(ActivatedBTN, 100.0);
        }
    }
}
ConsoleTuner Support Team
User avatar
J2Kbr
General of the Army
General of the Army
 
Posts: 20323
Joined: Tue Mar 18, 2014 1:39 pm

Re: What data type is BUTTON_1 and can i turn it into variab

Postby neit720 » Sun Sep 15, 2019 4:16 pm

Thank you! Really enjoy the Titan Two 1 year in :D
User avatar
neit720
Master Sergeant
Master Sergeant
 
Posts: 26
Joined: Sun Oct 21, 2018 10:25 am

Re: What data type is BUTTON_1 and can i turn it into variab

Postby J2Kbr » Mon Sep 16, 2019 10:22 am

You are welcome :)
ConsoleTuner Support Team
User avatar
J2Kbr
General of the Army
General of the Army
 
Posts: 20323
Joined: Tue Mar 18, 2014 1:39 pm


Return to GPC2 Script Programming

Who is online

Users browsing this forum: No registered users and 92 guests