Compiling issues Gtuner

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

Compiling issues Gtuner

Postby downtrodmasses » Thu Jan 05, 2023 9:22 pm

I have a titan one and wanted to make a script which allows for the following functions:

Recording a series of inputs, then replaying them in a loop until stopped.
I wanted it to trigger recording of the input loop with L1+R1, to then start/stop the loop with Cross + Circle, and then reset with Triangle + Square.

*edit, I also tried to get it to flash the LED red while recording the sequence, and green when looping it.

The idea was to be able to automated repeated tasks in many games.


Unfortunately the code keeps failing for various reasons.

The latest iteration of the code is as follows:
Code: Select all
define true = 1;
define false = 0;
 
 
 
// Initialize the variables with the button IDs
int trigger_input = 30;
int reset_input = 48;
int start_input = 7;
int stop_input = 8;
 
// Declare and initialize the flag to track the state of the loop
int loop_enabled = false;
 
// Declare and initialize the flag to track the state of the recording
int recording_enabled = false;
 
// Declare and initialize the counter to keep track of the current loop iteration
int loop_counter = 0;
 
// Create a function to handle the trigger input
function handle_trigger_input()
{
// Toggle the state of the loop
loop_enabled = !loop_enabled;
// If the loop is being enabled, reset the loop counter and set the LED to red
if (loop_enabled)
{
    loop_counter = 0;
    SetControllerLED(1, 0, 0);
}
// If the loop is being disabled, set the LED to green
else
{
    SetControllerLED(0, 1, 0);
}
}
 
// Create a function to handle the reset input
function handle_reset_input()
{
// If the loop is enabled, reset the loop counter
if (loop_enabled)
{
loop_counter = 0;
}
}
 
// Create a function to handle the start input
function handle_start_input()
{
// If the loop is enabled and not currently recording, start recording the loop
if (loop_enabled && !recording_enabled)
{
StartRecording();
recording_enabled = true;
}
}
 
// Create a function to handle the stop input
function handle_stop_input()
{
// If the loop is enabled and currently recording, stop recording the loop
if (loop_enabled && recording_enabled)
{
StopRecording();
recording_enabled = false;
}
}
 
// Define the ButtonPressed function
int ButtonPressed(int button)
{
return GetButtonState(button);
}
 
// Set up an event loop to run the script
while (true)
{
// Check for the trigger input
if (ButtonPressed(trigger_input))
{
handle_trigger_input();
}
 
// Check for the reset input
if (ButtonPressed(reset_input))
{
    handle_reset_input();
}
 
// Check for the start input
if (ButtonPressed(start_input))
{
    handle_start_input();
}
 
// Check for the stop input
if (ButtonPressed(stop_input))
{
    handle_stop_input();
}
 
// Sleep for a short time to avoid overloading the CPU
Sleep(10);
}
 
 

Errors:

GPC: GPC Compile ABORTED with 0 warning(s) and 19 error(s).
GPC: ----- GPC Compile: Automate inputs 3.gpc -----
GPC: Preprocessor started.
GPC: First-pass started.
GPC: Variables: Global: 7, Local: 0, Parameters: 1, Pointers: 0, Constants: 0, Labels: 0, Functions: 5, Combos: 0
GPC: Memory usage: Static: 16 bytes (1.56%), Dynamic: 4 bytes (0.39%)
GPC: Second-pass started.
GPC error: Automate inputs 3.gpc(29): Identifier not declared 'SetControllerLED'.
GPC error: Automate inputs 3.gpc(29): Illegal operation 'arg:1'.
GPC error: Automate inputs 3.gpc(29): Illegal operation 'arg:1'.
GPC error: Automate inputs 3.gpc(29): Illegal operation 'arg:1'.
GPC error: Automate inputs 3.gpc(29): Illegal function call, near ')'
GPC error: Automate inputs 3.gpc(34): Identifier not declared 'SetControllerLED'.
GPC error: Automate inputs 3.gpc(34): Illegal operation 'arg:1'.
GPC error: Automate inputs 3.gpc(34): Illegal operation 'arg:1'.
GPC error: Automate inputs 3.gpc(34): Illegal operation 'arg:1'.
GPC error: Automate inputs 3.gpc(34): Illegal function call, near ')'
GPC error: Automate inputs 3.gpc(54): Identifier not declared 'StartRecording'.
GPC error: Automate inputs 3.gpc(54): Illegal function call, near ')'
GPC error: Automate inputs 3.gpc(65): Identifier not declared 'StopRecording'.
GPC error: Automate inputs 3.gpc(65): Illegal function call, near ')'
GPC error: Automate inputs 3.gpc(73): Identifier not declared 'GetButtonState'.
GPC error: Automate inputs 3.gpc(73): Illegal operation 'arg:1'.
GPC error: Automate inputs 3.gpc(73): Illegal function call, near ')'
GPC error: Automate inputs 3.gpc(73): Incompatible return value 'ButtonPressed'.
GPC error: Automate inputs 3.gpc(77): syntax error, unexpected WHILE 'while'.
GPC: GPC Compile ABORTED with 0 warning(s) and 19 error(s).

Please can anyone offer any advice how I can fix this code?
User avatar
downtrodmasses
Private First Class
Private First Class
 
Posts: 3
Joined: Thu Jan 05, 2023 7:57 pm

Re: Compiling issues Gtuner

Postby downtrodmasses » Thu Jan 05, 2023 11:07 pm

Forgot to actually add in the errors, fixed, sorry lol.
User avatar
downtrodmasses
Private First Class
Private First Class
 
Posts: 3
Joined: Thu Jan 05, 2023 7:57 pm

Re: Compiling issues Gtuner

Postby downtrodmasses » Thu Jan 05, 2023 11:47 pm

update... sorry I got things a bit confused as I actually forgot I had both Gtuner Pro v3.70 and also Gtuner IV 1.11 open at the same time and I got a bit confused...

The errors above are from the Gtuner IV app.

The code I gave was taken from Gtuner Pro lol... as I've been tinkering on both, with no success...

The error from the Gtuner Pro app is as follows. Sorry folks, been a long couple of days lol.

> 2: New* :
> ERROR line 21: syntax error near unexpected token '{'.
Build failed with 1 errors ...

Lines 18-29 for reference:

"// Declare and initialize the counter to keep track of the current loop iteration
int loop_counter = 0;

{
// Toggle the state of the loop
loop_enabled = !loop_enabled;
// If the loop is being enabled, reset the loop counter and set the LED to red
if (loop_enabled)
{
loop_counter = 0;
SetControllerLED(1, 0, 0);
}"
User avatar
downtrodmasses
Private First Class
Private First Class
 
Posts: 3
Joined: Thu Jan 05, 2023 7:57 pm

Re: Compiling issues Gtuner

Postby Scachi » Fri Jan 06, 2023 10:34 am

Your code doesn't seem to be complete. You don't have a main section at all, SetControllerLED is not defined ...
and you should get used to use some better code formatting to be able to spot the begin and end of each function with a quick view. That way you will get more help. It is hard to read atm.
Also do small code changes/addition each time and hit the compile button often to easily spot the area when stuff starts to fail compile.
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany


Return to GPC1 Script Programming

Who is online

Users browsing this forum: No registered users and 69 guests