Mega guide to converting your old scripts for Titan Two
Mega guide to converting your old scripts for Titan Two
LAST UPDATED: 26 FEB 2018
UPDATE REASON: step #4 is no longer needed due to an update to T2
************************************************************************************************************************************
Warning: This is a work in progress! I must emphasise that I'm literally figuring this out as I go; I'm looking at code samples and making educated guesses, so I will need all your help to fine tune this. This will be an evolving guide.
Gtuner IV Download: http://www.consoletuner.com/forum/viewt ... =23&t=4600
************************************************************************************************************************************
Automatic Script Conversion / T1 Backwards Compatibility:
In the future J2Kbr will be allowing us to add this header file: #include <gpc_converter.gph> to the beginning of each script, which will automatically convert it for you. However, for now, this header file is not available yet so you will need to convert your scripts. It'll be a good learning experience anyway and I'm sure plenty of you will want to bring your scripts kicking and screaming into the new era.
UPDATE 1: PaulaTheKoala has created a header file that enables limited backwards compatibility on Titan One functions. It is still a work in progress but you can view more information here:
http://www.consoletuner.com/forum/viewt ... =10#p34610
UPDATE 2: PaulaTheKoala has created a BC header file now. To use this, firstly download it here https://i.imgur.com/4TpBw1Z.jpg, and then include this at the top of your script: #include <T1.gph>
UPDATE 3: Scachi has put together a comprehensive guide on how to use the T1 header file: http://www.consoletuner.com/forum/viewt ... =26&t=5826
You can use this as-is, or alternatively if you only want to use specific functions (e.g. things that are no longer supported by T2), then you can open the T1.gph file and simply delete the functions that you don't need as they will interfere with the newer versions. Alternatively you can copy the functions you want to use directly into your script.
************************************************************************************************************************************
T2 Indexing the Normalized Data Structure:
The indexes have changed. I hope this is correct, I just created this using all the header files:
https://docs.google.com/spreadsheets/d/ ... sp=sharing
About: All GPC functions that handles with the normalized data structure receives as argument the index of which entry will be the object of operation. For this there is a set to predefined constants, where each one refers to a particular entry. The following table lists all available index constants and the value range of each one can take.
Note: see the link in the next section for more information on this.
************************************************************************************************************************************
>>>>> STEP 1
If you want to continue using the button references that you are used to (e.g. PS4_LY), then add this header file to the top of your script:
For more information on header files, please see the following thread:
http://www.consoletuner.com/forum/viewt ... =23&t=4641
************************************************************************************************************************************
>>>>> STEP 2
All of your "define" variables will need to be changed from this:
To this:
************************************************************************************************************************************
>>>>> STEP 3
All of your boolean variables will need to be changed from this:
To this:
************************************************************************************************************************************
>>>>> STEP 4
If you are using any boolean variables, add this to your list of variables:
************************************************************************************************************************************
>>>>> STEP 5
When you are comparing a button with a number (e.g. stick or trigger pressed greater than 50%), you will need to convert the button press to an int. Note that this is only applicable to the get_val function. So change this:
To this:
Alternative options:
PaulaTheKoala has also suggested if you don't want to do lots of casting and keep your variables as int, you could always create and use your own function:
More examples here: http://www.consoletuner.com/forum/viewt ... =10#p34438
NOTE 1: from J2Kbr: "set_val is the only IO function that accepts fix32 and int as values. If an int is provided, it internally converts to fix32. I did this to make easy use int values to set the outputs without use type cast, or be forced to use 32bits variables where it is not needed."
************************************************************************************************************************************
>>>>> STEP 6
Now run the compiler by pressing F7, and step through all the function changes that are required. Do a Replace All (obviously great care needs to be taken at this point). So for example, event_active() is the new event_pressed(), time_active() is the new get_ptime(), and elapsed_time() is the new get_rtime(). Use the following lookup table to do your conversions:
https://docs.google.com/spreadsheets/d/ ... sp=sharing (THIS IS A PRIVATE SHEET DO NOT SHARE THIS LINK OUTSIDE THIS FORUM)
NOTE 1: Some things are no longer handled through combos, such as combo_running(), so you may not be able to do a simple Replace All in every situation.
NOTE 2: I have allowed public editing so you are welcome to contribute to this if you want.
IMPORTANT: As of 24 Sep, some function names have changed. See Column C in the second tab for more details (https://docs.google.com/spreadsheets/d/ ... id=9327721)
************************************************************************************************************************************
>>>>> STEP 7
Update your functions as follows:
So this:
Becomes this:
************************************************************************************************************************************
>>>>> NEW / FUN STUFF
The_Rabid_Taco has kindly added an example LED script to the GTuner IV library, called "LED_Example". Follow these steps to download it: https://i.imgur.com/wb1xFN6.jpg
UPDATE REASON: step #4 is no longer needed due to an update to T2
************************************************************************************************************************************
Warning: This is a work in progress! I must emphasise that I'm literally figuring this out as I go; I'm looking at code samples and making educated guesses, so I will need all your help to fine tune this. This will be an evolving guide.
Gtuner IV Download: http://www.consoletuner.com/forum/viewt ... =23&t=4600
************************************************************************************************************************************
Automatic Script Conversion / T1 Backwards Compatibility:
In the future J2Kbr will be allowing us to add this header file: #include <gpc_converter.gph> to the beginning of each script, which will automatically convert it for you. However, for now, this header file is not available yet so you will need to convert your scripts. It'll be a good learning experience anyway and I'm sure plenty of you will want to bring your scripts kicking and screaming into the new era.
UPDATE 1: PaulaTheKoala has created a header file that enables limited backwards compatibility on Titan One functions. It is still a work in progress but you can view more information here:
http://www.consoletuner.com/forum/viewt ... =10#p34610
UPDATE 2: PaulaTheKoala has created a BC header file now. To use this, firstly download it here https://i.imgur.com/4TpBw1Z.jpg, and then include this at the top of your script: #include <T1.gph>
UPDATE 3: Scachi has put together a comprehensive guide on how to use the T1 header file: http://www.consoletuner.com/forum/viewt ... =26&t=5826
You can use this as-is, or alternatively if you only want to use specific functions (e.g. things that are no longer supported by T2), then you can open the T1.gph file and simply delete the functions that you don't need as they will interfere with the newer versions. Alternatively you can copy the functions you want to use directly into your script.
************************************************************************************************************************************
T2 Indexing the Normalized Data Structure:
The indexes have changed. I hope this is correct, I just created this using all the header files:
https://docs.google.com/spreadsheets/d/ ... sp=sharing
About: All GPC functions that handles with the normalized data structure receives as argument the index of which entry will be the object of operation. For this there is a set to predefined constants, where each one refers to a particular entry. The following table lists all available index constants and the value range of each one can take.
Note: see the link in the next section for more information on this.
************************************************************************************************************************************
>>>>> STEP 1
If you want to continue using the button references that you are used to (e.g. PS4_LY), then add this header file to the top of your script:
- Code: Select all
#include <ps4.gph> // for PS4
- Code: Select all
#include <ps3.gph> // for PS3
- Code: Select all
#include <xb1.gph> // for XB1
- Code: Select all
#include <xb360.gph> // for XB360
For more information on header files, please see the following thread:
http://www.consoletuner.com/forum/viewt ... =23&t=4641
************************************************************************************************************************************
>>>>> STEP 2
All of your "define" variables will need to be changed from this:
- Code: Select all
define MOV_Y_AXIS = PS4_LY;
To this:
- Code: Select all
#define MOV_Y_AXIS PS4_LY
************************************************************************************************************************************
>>>>> STEP 3
All of your boolean variables will need to be changed from this:
- Code: Select all
int run_flag = FALSE;
To this:
- Code: Select all
bool run_flag = FALSE;
************************************************************************************************************************************
>>>>> STEP 4
If you are using any boolean variables, add this to your list of variables:
- Code: Select all
#define TRUE !FALSE
************************************************************************************************************************************
>>>>> STEP 5
When you are comparing a button with a number (e.g. stick or trigger pressed greater than 50%), you will need to convert the button press to an int. Note that this is only applicable to the get_val function. So change this:
- Code: Select all
if(get_val(MOV_Y_AXIS) <= -97)
To this:
- Code: Select all
if((int) get_val(MOV_Y_AXIS) <= -97)
// use int or whatever type you want to convert to
Alternative options:
- Code: Select all
if(get_val(MOV_Y_AXIS) <= -97.00)
- Code: Select all
if(get_val(MOV_Y_AXIS) <= -97f)
PaulaTheKoala has also suggested if you don't want to do lots of casting and keep your variables as int, you could always create and use your own function:
- Code: Select all
int get_val2(uint8 input)
{
return (int) get_val(input);
}
More examples here: http://www.consoletuner.com/forum/viewt ... =10#p34438
NOTE 1: from J2Kbr: "set_val is the only IO function that accepts fix32 and int as values. If an int is provided, it internally converts to fix32. I did this to make easy use int values to set the outputs without use type cast, or be forced to use 32bits variables where it is not needed."
************************************************************************************************************************************
>>>>> STEP 6
Now run the compiler by pressing F7, and step through all the function changes that are required. Do a Replace All (obviously great care needs to be taken at this point). So for example, event_active() is the new event_pressed(), time_active() is the new get_ptime(), and elapsed_time() is the new get_rtime(). Use the following lookup table to do your conversions:
https://docs.google.com/spreadsheets/d/ ... sp=sharing (THIS IS A PRIVATE SHEET DO NOT SHARE THIS LINK OUTSIDE THIS FORUM)
NOTE 1: Some things are no longer handled through combos, such as combo_running(), so you may not be able to do a simple Replace All in every situation.
NOTE 2: I have allowed public editing so you are welcome to contribute to this if you want.
IMPORTANT: As of 24 Sep, some function names have changed. See Column C in the second tab for more details (https://docs.google.com/spreadsheets/d/ ... id=9327721)
************************************************************************************************************************************
>>>>> STEP 7
Update your functions as follows:
So this:
- Code: Select all
function SetAntiRecoilMode(m) {
Becomes this:
- Code: Select all
void SetAntiRecoilMode(int m) {
************************************************************************************************************************************
>>>>> NEW / FUN STUFF
The_Rabid_Taco has kindly added an example LED script to the GTuner IV library, called "LED_Example". Follow these steps to download it: https://i.imgur.com/wb1xFN6.jpg
Last edited by pablosscripts on Sun Oct 23, 2016 10:31 pm, edited 61 times in total.
Setup: XIM Apex, T2, K780 keyboard, G Pro Wireless mouse, SteelSeries 4HD pad, DXRacer armrest, LucidSound LS30 headset, Netduma router, Ubiquiti UniFi AP LR
My R6 script: https://youtu.be/x-9NtxyySVM
My R6 script: https://youtu.be/x-9NtxyySVM
-
pablosscripts - Brigadier General
- Posts: 1976
- Joined: Tue Nov 24, 2015 6:27 am
Re: Mega guide to converting your old scripts for Titan Two
Great job pablogroup !
- bonefisher
- Lieutenant General
- Posts: 5413
- Joined: Thu Jan 29, 2015 10:49 am
Re: Mega guide to converting your old scripts for Titan Two
I've added some additional tips from PaulaTheKoala.
Setup: XIM Apex, T2, K780 keyboard, G Pro Wireless mouse, SteelSeries 4HD pad, DXRacer armrest, LucidSound LS30 headset, Netduma router, Ubiquiti UniFi AP LR
My R6 script: https://youtu.be/x-9NtxyySVM
My R6 script: https://youtu.be/x-9NtxyySVM
-
pablosscripts - Brigadier General
- Posts: 1976
- Joined: Tue Nov 24, 2015 6:27 am
Re: Mega guide to converting your old scripts for Titan Two
I've now added a lookup table to do your function() conversions:
https://docs.google.com/spreadsheets/d/ ... sp=sharing (THIS IS A PRIVATE SHEET DO NOT SHARE THIS LINK OUTSIDE THIS FORUM)
https://docs.google.com/spreadsheets/d/ ... sp=sharing (THIS IS A PRIVATE SHEET DO NOT SHARE THIS LINK OUTSIDE THIS FORUM)
Setup: XIM Apex, T2, K780 keyboard, G Pro Wireless mouse, SteelSeries 4HD pad, DXRacer armrest, LucidSound LS30 headset, Netduma router, Ubiquiti UniFi AP LR
My R6 script: https://youtu.be/x-9NtxyySVM
My R6 script: https://youtu.be/x-9NtxyySVM
-
pablosscripts - Brigadier General
- Posts: 1976
- Joined: Tue Nov 24, 2015 6:27 am
Re: Mega guide to converting your old scripts for Titan Two
Was trying to convert one of my scripts, only error is this:
GPC error: sdf.gpc(32): syntax error, unexpected ASSIGN '='.
GPC error: sdf.gpc(32): syntax error, unexpected ASSIGN '='.
XB360, XB1
GT: Valant
GT: Valant
-
Valant - Lieutenant
- Posts: 355
- Joined: Thu Nov 06, 2014 3:11 am
- Location: Colorado, USA
Re: Mega guide to converting your old scripts for Titan Two
Valant wrote:Was trying to convert one of my scripts, only error is this:
GPC error: sdf.gpc(32): syntax error, unexpected ASSIGN '='.
Can you paste line 32 and I'll take a look.
Setup: XIM Apex, T2, K780 keyboard, G Pro Wireless mouse, SteelSeries 4HD pad, DXRacer armrest, LucidSound LS30 headset, Netduma router, Ubiquiti UniFi AP LR
My R6 script: https://youtu.be/x-9NtxyySVM
My R6 script: https://youtu.be/x-9NtxyySVM
-
pablosscripts - Brigadier General
- Posts: 1976
- Joined: Tue Nov 24, 2015 6:27 am
Re: Mega guide to converting your old scripts for Titan Two
- Code: Select all
init {
hold_time1 = 500 / RATE_OF_FIRE1;
rest_time1 = hold_time1 - 20;
if(rest_time1 < 0) rest_time1 = 0;
hold_time2 = 500 / RATE_OF_FIRE2;
rest_time2 = hold_time2 - 20;
if(rest_time2 < 0) rest_time2 = 0;
if(get_console() == PIO_XB360) { // XB360 Trigger & Bumper
fire_button = 3;
scope_button = 6;
} else { // Natural Trigger & Bumper
fire_button = 4;
scope_button = 7;
}
}
^line 31 through 46
XB360, XB1
GT: Valant
GT: Valant
-
Valant - Lieutenant
- Posts: 355
- Joined: Thu Nov 06, 2014 3:11 am
- Location: Colorado, USA
Re: Mega guide to converting your old scripts for Titan Two
Now whats weird there is the PIO_XB360 there is legal, but on a different script
line 37 through 49
I get the following errors unlike the other one:
GPC error: Anti-Recoil + Rapid Fire.gpc(38): Illegal function call, near ')'
GPC error: Anti-Recoil + Rapid Fire.gpc(38): Identifier not declared 'PIO_XB360'.
GPC error: Anti-Recoil + Rapid Fire.gpc(38): Illegal operation '=='.
GPC error: Anti-Recoil + Rapid Fire.gpc(46): syntax error, unexpected ASSIGN '='.
Except for the last one
- Code: Select all
init {
if(get_console() == PIO_XB360) { // Xbox 360 Trigger & Bumper
fire_button = 3;
scope_button = 6;
} else { // Natural Trigger & Bumper
fire_button = 4;
scope_button = 7;
}
hold_time = 500 / RATE_OF_FIRE;
rest_time = hold_time - 20;
if(rest_time < 0) rest_time = 0;
}
line 37 through 49
I get the following errors unlike the other one:
GPC error: Anti-Recoil + Rapid Fire.gpc(38): Illegal function call, near ')'
GPC error: Anti-Recoil + Rapid Fire.gpc(38): Identifier not declared 'PIO_XB360'.
GPC error: Anti-Recoil + Rapid Fire.gpc(38): Illegal operation '=='.
GPC error: Anti-Recoil + Rapid Fire.gpc(46): syntax error, unexpected ASSIGN '='.
Except for the last one
XB360, XB1
GT: Valant
GT: Valant
-
Valant - Lieutenant
- Posts: 355
- Joined: Thu Nov 06, 2014 3:11 am
- Location: Colorado, USA
Re: Mega guide to converting your old scripts for Titan Two
gpc compiler is not that good at giving error information.
there is not a get_console() function thats is why you see all those errors if you add your own get_console() function and change PIO_XB360 constant for example to 3, the script will compile without errors.
there is not a get_console() function thats is why you see all those errors if you add your own get_console() function and change PIO_XB360 constant for example to 3, the script will compile without errors.
-
FCB77 - Command Sergeant Major
- Posts: 138
- Joined: Sun Feb 01, 2015 9:21 am
Return to GPC2 Script Programming
Who is online
Users browsing this forum: midg3t2 and 92 guests