Help with script
11 posts
• Page 1 of 2 • 1, 2
Help with script
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!
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!
-
MichaelS - Staff Sergeant
- Posts: 12
- Joined: Sat Aug 24, 2019 5:12 pm
Re: Help with script
GPC Language Reference: https://www.consoletuner.com/kbase/gpc_ ... s=AgAAAQ==
Quick example to get you started:
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
- Posts: 4536
- Joined: Wed May 22, 2019 5:39 am
Re: Help with script
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?
Also how can I make simultaneous inputs that may start or end at different times but still overlap each other?
-
MichaelS - Staff Sergeant
- Posts: 12
- Joined: Sat Aug 24, 2019 5:12 pm
Re: Help with script
- 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
- Posts: 4536
- Joined: Wed May 22, 2019 5:39 am
Re: Help with script
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?
-
MichaelS - Staff Sergeant
- Posts: 12
- Joined: Sat Aug 24, 2019 5:12 pm
Re: Help with script
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
- Posts: 4536
- Joined: Wed May 22, 2019 5:39 am
Re: Help with script
What if I wanted to press different buttons at different times with overlap within a combo?
for example would the code above hold A, then wait 1 second then hold B for 1 second, and then release A?
- 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?
-
MichaelS - Staff Sergeant
- Posts: 12
- Joined: Sat Aug 24, 2019 5:12 pm
Re: Help with script
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
-
J2Kbr - General of the Army
- Posts: 20323
- Joined: Tue Mar 18, 2014 1:39 pm
Re: Help with script
In that code, A is not being released until the last second has passed correct?
-
MichaelS - Staff Sergeant
- Posts: 12
- Joined: Sat Aug 24, 2019 5:12 pm
Re: Help with script
Yes, A is held for 2 seconds and B is held for one second.
ConsoleTuner Support Team || ConsoleTuner Discord || InputSense Discord
- Mad
- Major General
- Posts: 4536
- Joined: Wed May 22, 2019 5:39 am
11 posts
• Page 1 of 2 • 1, 2
Return to GPC1 Script Programming
Who is online
Users browsing this forum: No registered users and 87 guests