First Timer, Need Help With Simple Script

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

First Timer, Need Help With Simple Script

Postby cairo1725 » Wed Nov 10, 2021 5:17 am

I want to make a trial script to mess around with in game. The script is pretty simple. When I press the back button on Xbox, the Script automatically presses down on D pad twice, then A, then B, all rapidly. Allowing me to access inventory, scroll to medical item, and use it and back out of menu. The only thing is that I never made a script before and I tried reading up on combo commands but do not know how to properly apply it here, any help with code is appreciated, thanks.
User avatar
cairo1725
Sergeant
Sergeant
 
Posts: 8
Joined: Wed Nov 10, 2021 5:13 am

Re: First Timer, Need Help With Simple Script

Postby Coilover » Wed Nov 10, 2021 3:52 pm

Hi,
From memory the answer will be something like this..

Code: Select all
main {
    if (is_active(BUTTON_15)) combo_run(cMyCombo) // if you press B then run the combo;
}
 
combo cMyCombo {
    set_val(BUTTON_11,100); // press BUTTON11 (D-Pad down)
    wait(40); // (press) for 40ms
    set_val(BUTTON_11,0);   // release BUTTON11 (D-Pad down)
    wait(40); // (release) for 40ms
    set_val(BUTTON_11,100); // press BUTTON11 (D-Pad down)
    wait(40); // (press) for 40ms
    set_val(BUTTON_11,0);   // release BUTTON11 (D-Pad down)
    wait(40); // (release) for 40ms
    set_val(BUTTON_16,100); // press BUTTON16 (A)
    wait(40); // (press) for 40ms
    set_val(BUTTON_16,0);   // release BUTTON16 (A)
    wait(40); // (release) for 40ms
    set_val(BUTTON_15,100); // press BUTTON15 (B)
    wait(40); // (press) for 40ms
    set_val(BUTTON_15,0);   // release BUTTON15 (B)
    wait(40); // (release) for 40ms
}
 


You might want to add a script to trap to prevent the button press being detected multiple times and running the combo more than once. There is a lot of useful examples of code and information here https://www.consoletuner.com/wiki/index ... examples_1
User avatar
Coilover
Staff Sergeant
Staff Sergeant
 
Posts: 15
Joined: Thu Nov 04, 2021 6:59 pm

Re: First Timer, Need Help With Simple Script

Postby Coilover » Wed Nov 10, 2021 3:58 pm

... this script in the examples does a lot of what you want. Just change the button numbers for the buttons you want.

Code: Select all
bool bEnabled=FALSE;
 
main {
  if (event_active(BUTTON_17) && time_release(BUTTON_17) <= 200) { // start
      bEnabled = TRUE;
      printf("Double Tap");
  }
  if (event_release(BUTTON_17)) bEnabled = FALSE; // stop repeating on release
 
  if (bEnabled) combo_run(cRepeat);
}
 
combo cRepeat {
  set_val(BUTTON_17,100); // press button
  wait(200);              // (press) for 200ms
  set_val(BUTTON_17,0);   // release button
  wait(200);              // (release) for 200ms
}
User avatar
Coilover
Staff Sergeant
Staff Sergeant
 
Posts: 15
Joined: Thu Nov 04, 2021 6:59 pm


Return to GPC2 Script Programming

Who is online

Users browsing this forum: No registered users and 103 guests