Crash course to create your GPH Header file
10 posts
• Page 1 of 1
Crash course to create your GPH Header file
Here is an example on how to use an header file to use several scripts in one, create a new gph file and paste that according to your gph file name at the top of your script:
And paste that at the end of your script:
You can create any script or function as gph and use it with any other script.
paste that according to your gph file name and location at the top of your script to use your header file:
If you see anything to add please comment.
- Code: Select all
#ifndef My_Layout_
#define My_Layout_GPH_
And paste that at the end of your script:
- Code: Select all
#endif /* My_Layout_GPH_ */
- Code: Select all
#ifndef My_Layout_
#define My_Layout_GPH_
#include <keyboard.gph>
#include <mouse.gph>
main {
// For the keyboard
if(key_status(KEY_A)) {
set_val(BUTTON_15, 100);
}
if(key_status(KEY_B)) {
set_val(BUTTON_15, 100);
}
// For the mouse
if(key_status(MBUTTON_1)) {
set_val(BUTTON_15, 100);
}
if(key_status(MBUTTON_2)) {
set_val(BUTTON_15, 100);
}
}
#endif /* My_Layout_GPH_ */
You can create any script or function as gph and use it with any other script.
paste that according to your gph file name and location at the top of your script to use your header file:
- Code: Select all
#include <C:/GtunerIVBeta/Layout/My_Layout.gph>
main {
}
If you see anything to add please comment.
Console tuner since my 1st controller.
Scripting, a game in the game.
Believe or dare, It's Titanic!
Scripting, a game in the game.
Believe or dare, It's Titanic!
-
Prototype - Major General
- Posts: 3252
- Joined: Sun Dec 16, 2012 1:43 pm
Re: Crash course to create your GPH Header file
you can use something like:
to have a relative more portable path and put all your gph file in include directory (or any other , just change the name)
you should also have 2 type of variables:
- those you can restrict to a single gph file and as a good practice prefix them with the file name e.g.: layout_var1 layout_var2
- those you will use in multiple gph files
for the later it it better to define them in a common.gph file that you will #include first (the order matter)
also you should start to convert all the get_val() to get_actual() otherwise your script may act oddly depending on the order you call the include files.
these are emu personal tips after i "modularised" one of my script.
- Code: Select all
#include "include/My_Layout.gph"
to have a relative more portable path and put all your gph file in include directory (or any other , just change the name)
you should also have 2 type of variables:
- those you can restrict to a single gph file and as a good practice prefix them with the file name e.g.: layout_var1 layout_var2
- those you will use in multiple gph files
for the later it it better to define them in a common.gph file that you will #include first (the order matter)
also you should start to convert all the get_val() to get_actual() otherwise your script may act oddly depending on the order you call the include files.
these are emu personal tips after i "modularised" one of my script.
Last edited by paname on Mon Apr 24, 2017 1:23 pm, edited 1 time in total.
-
paname - Sergeant Major of the Army
- Posts: 204
- Joined: Wed Jan 07, 2015 3:02 pm
Re: Crash course to create your GPH Header file
Yes that's what i usually do but it's easy to have those files in separated folders.
I forgot to specify that, thanks for your input.
I forgot to specify that, thanks for your input.
Console tuner since my 1st controller.
Scripting, a game in the game.
Believe or dare, It's Titanic!
Scripting, a game in the game.
Believe or dare, It's Titanic!
-
Prototype - Major General
- Posts: 3252
- Joined: Sun Dec 16, 2012 1:43 pm
Re: Crash course to create your GPH Header file
what i mean is you can do :
no need to put
- Code: Select all
#include "module1/file1.gph"
#include "module2/file2.gph"
#include "module3/file3.gph"
no need to put
- Code: Select all
#include <C:/DD/DD//D//D/module1/file1.gph>
#include <C:/DD/DD//D//D/module2/file2.gph>
#include <C:/DD/DD//D//D/module3/file3.gph>
-
paname - Sergeant Major of the Army
- Posts: 204
- Joined: Wed Jan 07, 2015 3:02 pm
Re: Crash course to create your GPH Header file
I don't use so much header files and they are not all in my include folder but yes you can do both as you like
Console tuner since my 1st controller.
Scripting, a game in the game.
Believe or dare, It's Titanic!
Scripting, a game in the game.
Believe or dare, It's Titanic!
-
Prototype - Major General
- Posts: 3252
- Joined: Sun Dec 16, 2012 1:43 pm
Re: Crash course to create your GPH Header file
A relative path is simpler and more robust, but absolute will work.
Using includes (preferably relative) is definitely the way forward for compartmentalisation and code maintenance, and will greatly expedite script development.
Good candidates for headers are bindings, combos and functions that are typically recycled from script to script.
On that subject, can #include be called from anywhere in a T2 script? I'm still largely splashing around the T1 kiddy pool and have yet to dive into serious T2 scripting.
Using includes (preferably relative) is definitely the way forward for compartmentalisation and code maintenance, and will greatly expedite script development.
Good candidates for headers are bindings, combos and functions that are typically recycled from script to script.
On that subject, can #include be called from anywhere in a T2 script? I'm still largely splashing around the T1 kiddy pool and have yet to dive into serious T2 scripting.
-
antithesis - Colonel
- Posts: 1912
- Joined: Sat May 28, 2016 10:45 pm
Re: Crash course to create your GPH Header file
antithesis wrote:On that subject, can #include be called from anywhere in a T2 script?
yes, there is no restriction on this matter.
ConsoleTuner Support Team
-
J2Kbr - General of the Army
- Posts: 20323
- Joined: Tue Mar 18, 2014 1:39 pm
Re: Crash course to create your GPH Header file
Thanks for the tips guys, i'm going to begin to use Header files more efficiently!
Console tuner since my 1st controller.
Scripting, a game in the game.
Believe or dare, It's Titanic!
Scripting, a game in the game.
Believe or dare, It's Titanic!
-
Prototype - Major General
- Posts: 3252
- Joined: Sun Dec 16, 2012 1:43 pm
Re: Crash course to create your GPH Header file
When I try to include a headfile of my PC with:
But when I enter the full path of this headerfile it works, what's the issue?
- Code: Select all
#include "DisplayPrinter.gph"
But when I enter the full path of this headerfile it works, what's the issue?
Check out my YouTube Channel: https://www.youtube.com/c/xXSkyWalkerXx1
& my website: https://skymodz.com
& my website: https://skymodz.com
-
xXSkyWalkerXx_1 - Sergeant Major
- Posts: 106
- Joined: Thu Sep 13, 2018 11:05 am
- Location: Germany
Re: Crash course to create your GPH Header file
The one without the path will only work if the header file is located in the same directory as your script you have this line in.
It works too if the header file is in the include directory of your gtuner software. But don't do that, that is bad practice.
This directory should only be used by the header files that comes with the gtuner software itself.
Take a look on relative paths for include files some way up in this thread or google for it.
It works too if the header file is in the include directory of your gtuner software. But don't do that, that is bad practice.
This directory should only be used by the header files that comes with the gtuner software itself.
Take a look on relative paths for include files some way up in this thread or google for it.
-
Scachi - Brigadier General
- Posts: 3044
- Joined: Wed May 11, 2016 6:25 am
- Location: Germany
10 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 40 guests