Help with script

GPC1 script programming for Titan One. Code examples, questions, requests.

Help with script

Postby MichaelS » Sat Aug 24, 2019 5:19 pm

Hello, I am new to this forum. I have very basic coding knowledge with python. If it were possible could someone guide me through a way to program a controller to perform a set sequence of inputs for a racing game? It is pretty much an attempt at perfect gameplay.

1. The script needs to hold the accelerate button throughout the entire race

2. The code should outline the exact times for an input to be pressed as well as the wait times between inputs

3. The code should be able to perform joystick angles as inputs.


It would be greatly appreciated if someone could outline how I could perform these things, or if someone could give some exemplar code to get me started.


Thanks in advance!
User avatar
MichaelS
Staff Sergeant
Staff Sergeant
 
Posts: 12
Joined: Sat Aug 24, 2019 5:12 pm

Re: Help with script

Postby Mad » Sat Aug 24, 2019 8:56 pm

GPC Language Reference: https://www.consoletuner.com/kbase/gpc_ ... s=AgAAAQ==

Quick example to get you started:
Code: Select all
int toggle;
 
main {
  if (event_press(XB1_LEFT)) toggle = !toggle; // Dpad left enables / disables the combo
 
  if (toggle) combo_run(Example); // Toggle enabled, run the combo
  else combo_stop(Example); // Toggle disabled, stop the combo
}
 
combo Example {
  set_val(XB1_RT, 100);
  wait(3000); // Hold RT for 3 seconds
  wait(100); // Time between inputs
  set_val(XB1_RX, -70); // Right stick movement to -70
  wait(200); // Hold stick for 200ms
}
ConsoleTuner Support Team || ConsoleTuner Discord || InputSense Discord
Mad
Major General
Major General
 
Posts: 4536
Joined: Wed May 22, 2019 5:39 am

Re: Help with script

Postby MichaelS » Sat Aug 24, 2019 9:01 pm

Thanks! I was wondering how exactly the values for the joystick angles work. If I wanted to put the joystick fully perhaps a little bit lower than a perfect diagonal, what kind of value should I use?

Also how can I make simultaneous inputs that may start or end at different times but still overlap each other?
User avatar
MichaelS
Staff Sergeant
Staff Sergeant
 
Posts: 12
Joined: Sat Aug 24, 2019 5:12 pm

Re: Help with script

Postby Mad » Sun Aug 25, 2019 4:47 am

Code: Select all
main {
    // Up
    set_val(XB1_RX, 0.0);
    set_val(XB1_RY, -100.0);
 
    // Up-Right
    set_val(XB1_RX, 100.0);
    set_val(XB1_RY, -100.0);
 
    // Right
    set_val(XB1_RX, 100.0);
    set_val(XB1_RY, 0.0);
 
    // Right-Down
    set_val(XB1_RX, 100.0);
    set_val(XB1_RY, 100.0);
 
    // Down
    set_val(XB1_RX, 0.0);
    set_val(XB1_RY, 100.0);
 
    // Down-Left
    set_val(XB1_RX, -100.0);
    set_val(XB1_RY, 100.0);
 
    // Left
    set_val(XB1_RX, -100.0);
    set_val(XB1_RY, 0.0);
 
    // Left-Up
    set_val(XB1_RX, -100.0);
    set_val(XB1_RY, -100.0);
}


You can create multiple combo's and run them at the same time.

You may want to look into recording macros: https://www.consoletuner.com/kbase/plug ... s=AQAAIA==
ConsoleTuner Support Team || ConsoleTuner Discord || InputSense Discord
Mad
Major General
Major General
 
Posts: 4536
Joined: Wed May 22, 2019 5:39 am

Re: Help with script

Postby MichaelS » Sun Aug 25, 2019 12:50 pm

Could I get an example script where: A button is pressed down, and then some time later a different button is pressed but while the other button is still pressed and the second button is lifted off of before the first?
User avatar
MichaelS
Staff Sergeant
Staff Sergeant
 
Posts: 12
Joined: Sat Aug 24, 2019 5:12 pm

Re: Help with script

Postby Mad » Sun Aug 25, 2019 8:05 pm

Depends how you need to do it.

Code: Select all
main {
  if (get_val(XB1_A)) {
    set_val(XB1_B, 100); // B is held while A is held
    combo_run(Example);
  }
}
 
combo Example {
  wait(500);
  set_val(XB1_X, 100); // X is pressed 500 ms after B
  wait(1000); // X held for 1000ms
}
 


Code: Select all
main {
  if (get_val(XB1_A)) {
    combo_run(Example);
    combo_run(Example2);
  }
}
 
combo Example {
  set_val(XB1_X, 100); // Hold X for 4000ms
  wait(4000);
}
 
combo Example2 {
  wait(500); // wait 500 ms after x is held
  set_val(XB1_Y, 100); // x is still held, and y is held
  wait(1000); // for 1000ms
}
ConsoleTuner Support Team || ConsoleTuner Discord || InputSense Discord
Mad
Major General
Major General
 
Posts: 4536
Joined: Wed May 22, 2019 5:39 am

Re: Help with script

Postby MichaelS » Mon Aug 26, 2019 6:52 pm

What if I wanted to press different buttons at different times with overlap within a combo?
Code: Select all
combo something1;
    wait(1000);
    set_val(XB1_B, 100);
    wait(1000);
    set_val(XB1_A, 0);
 
combo something2;
    set_val(XB1_A, 100);
    combo_run(something1);

for example would the code above hold A, then wait 1 second then hold B for 1 second, and then release A?
User avatar
MichaelS
Staff Sergeant
Staff Sergeant
 
Posts: 12
Joined: Sat Aug 24, 2019 5:12 pm

Re: Help with script

Postby J2Kbr » Mon Aug 26, 2019 7:07 pm

MichaelS wrote:for example would the code above hold A, then wait 1 second then hold B for 1 second, and then release A?

For that the best would be use a single combo (with two combos is also possible, but more complicated).
Code: Select all
combo Something {
    set_val(XB1_A, 100.0);
    wait(1000);
    set_val(XB1_A, 100.0);
    set_val(XB1_B, 100.0);
    wait(1000);
}

There is no need to set A to 0 for release (unless you want overwrite the input from the controller).
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: Help with script

Postby MichaelS » Mon Aug 26, 2019 7:16 pm

In that code, A is not being released until the last second has passed correct?
User avatar
MichaelS
Staff Sergeant
Staff Sergeant
 
Posts: 12
Joined: Sat Aug 24, 2019 5:12 pm

Re: Help with script

Postby Mad » Mon Aug 26, 2019 8:48 pm

Yes, A is held for 2 seconds and B is held for one second.
ConsoleTuner Support Team || ConsoleTuner Discord || InputSense Discord
Mad
Major General
Major General
 
Posts: 4536
Joined: Wed May 22, 2019 5:39 am

Next

Return to GPC1 Script Programming

Who is online

Users browsing this forum: No registered users and 74 guests