Need help so when you press a button it activates the script

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

Need help so when you press a button it activates the script

Postby lBOYDl » Sun Dec 09, 2018 4:08 pm

bool stick_forward;

Code: Select all
#include <titanone.gph>
 
//<titanone.gph>
// Fri Dec 07 2018 13:54:52
// Script generated by Visual to GPC
//----------------------------------------
 
main {
    if(event_press(XB1_X)) {
        combo_run(Tap_1);
        combo_run(Turbo_2);
    }
}
 
combo Tap_1 {
    set_val(XB1_X, 0);
    wait(400);
    set_val(XB1_X, 100);
    wait(40);
    set_val(XB1_X, 100);
}
 
combo Turbo_2 {
    set_val(XB1_X, 100);
    wait(50);
    set_val(XB1_X, 0);
 
    if(event_active(STICK_2_Y) && time_release(STICK_2_Y) < 240) {
    if(stick_forward == 0) {
        stick_forward = 1;
    }
    }
    if(stick_forward == 1){
        set_val(STICK_2_Y, -100);
    }
    if(is_active(STICK_2_X)){
        stick_forward = 0;
    }
}
User avatar
lBOYDl
Staff Sergeant
Staff Sergeant
 
Posts: 11
Joined: Sat Dec 08, 2018 7:33 am

Re: Need help so when you press a button it activates the sc

Postby Scachi » Sun Dec 09, 2018 5:04 pm

You can find some toggle and more example codes here: https://www.consoletuner.com/wiki/index ... examples_1
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Re: Need help so when you press a button it activates the sc

Postby Scachi » Sun Dec 09, 2018 5:07 pm

If you change
event_press to event_active
and
XB1_X to BUTTON_17
you have converted your script to gpc2 and don't need to use the titanone.gph header file.
If you want to keep the buttons names add that to the top of your script:
#include <xb1.gph>
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany


Return to GPC2 Script Programming

Who is online

Users browsing this forum: No registered users and 130 guests