GPC2 Language Reference

Tutorials, How-tos and FAQs for the Titan Two device.

Re: GPC2 Language Reference

Postby antithesis » Wed Jul 19, 2017 4:18 am

Thanks for the explanation J2K and thanks for the link paname.

Have you given any thought to additional aliases that provide more context than fix32 and int32? It's not necessary (I still don't get the difference between fix32 and int32), but it does dumb stuff down a bit for noobs.
Official Australian retailer for Titan One, Titan Two and XIM APEX at Mod Squad
User avatar
antithesis
Colonel
Colonel
 
Posts: 1912
Joined: Sat May 28, 2016 10:45 pm

Re: GPC2 Language Reference

Postby pablosscripts » Wed Jul 19, 2017 4:25 am

antithesis wrote:Thanks for the explanation J2K and thanks for the link paname.

Have you given any thought to additional aliases that provide more context than fix32 and int32? It's not necessary (I still don't get the difference between fix32 and int32), but it does dumb stuff down a bit for noobs.


Cool idea:) I'll add it to github!
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
User avatar
pablosscripts
Brigadier General
Brigadier General
 
Posts: 1976
Joined: Tue Nov 24, 2015 6:27 am

Re: GPC2 Language Reference

Postby J2Kbr » Mon Jul 24, 2017 3:17 pm

Additional aliases are very easy to implement. I am open for suggestions :)
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: GPC2 Language Reference

Postby pablosscripts » Mon Jul 24, 2017 5:57 pm

Ok just added this to github:

https://github.com/J2Kbr/GtunerIV/issues/165

Antithesis, if you have any suggestions now would be the time!
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
User avatar
pablosscripts
Brigadier General
Brigadier General
 
Posts: 1976
Joined: Tue Nov 24, 2015 6:27 am

Re: GPC2 Language Reference

Postby Shaag7 » Tue Oct 17, 2017 10:46 am

I was looking through the forums for all available datatypes explanation but wasn't successful.
I understand most of them, but I'm looking for following to have in Language Reference:
1. fix32 explanation(found some info in this thread)?
2. fix32 operations (i.e. I have adjustable antirecoil script, init value is i.e. 34, but when I printf the variable it gives me totally different number)?
3. is there any datatype to store alphanumerical strings (for display_overlay functions)?

There is snippet of my antirecoil adjustment for better explanation of my issue with fix32 operations:
Code: Select all
 
fix32 f_Recoil2               = 34.0;
...
if (l_AntiRecoil2 && !l_AntiRecoil3 && is_active(b_ADS) && !is_active(b_Fire) && i_WeaponType == 2) {
        if (event_active(b_Up)) {
            f_Recoil2 = f_Recoil2 - 1.0;
            printf("f_Recoil2:%d", f_Recoil2);
            }
        if (event_active(b_Down)) {
            f_Recoil2 = f_Recoil2 + 1.0;
            printf("f_Recoil2:%d", f_Recoil2);
            }
    }

I would like to add caps for adjustments like this, but due to my low know-how of this datatype and its operations / conversions, I'm stuck:
Code: Select all
        if (f_Recoil2 > 100) { f_Recoil2 = 100; }
        if (f_Recoil2 < -100) { f_Recoil2 = -100; }
PS4 - Titan2/Titan1 - Xim4 / XIM Apex - Logitech G502 Hero / Logitech G13 Advanced Gameboard / Logitech G213 Keyboard - DS4v2
User avatar
Shaag7
Command Sergeant Major
Command Sergeant Major
 
Posts: 121
Joined: Mon Sep 14, 2015 3:03 pm
Location: EU

Re: GPC2 Language Reference

Postby J2Kbr » Tue Oct 17, 2017 11:36 am

Shaag7 wrote:1. fix32 explanation(found some info in this thread)?

fix32 are number with decimal component. It is similar to float type in C. paname precisely explained the fix32 variable type here:
viewtopic.php?p=48931#p48931

Shaag7 wrote:2. fix32 operations (i.e. I have adjustable antirecoil script, init value is i.e. 34, but when I printf the variable it gives me totally different number)?

to print a fix32 use the %f format tag:
Code: Select all
printf("f_Recoil2:%f", f_Recoil2);

A list of all supported format tags can be found here:
https://www.consoletuner.com/wiki/index ... =t2:printf

Shaag7 wrote:3. is there any datatype to store alphanumerical strings (for display_overlay functions)?

The char type can be used to store string, example:
Code: Select all
char my_string[] = "My String";


However, for the display_overlay() function you need use an array with the bitmask of the characters:
Code: Select all
#pragma METAINFO("Display Overlay", 1, 0, "Example")
 
#include <display.gph>
 
main {
    combo_run(ShowString);
}
 
combo ShowString {
    const uint8 disp[] = { 0, _M_, _y_, 0, _S_, _t_, _r_, _i_, _n_, _g_ };
    static uint8 i;
 
    display_overlay(disp[i], 1000);
    if(++i >= sizeof(disp)) i = 0;
    wait(0);
 
    wait(980);
}
 
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: GPC2 Language Reference

Postby Shaag7 » Tue Oct 17, 2017 11:43 am

Thank you for fast response :smile0517: .
I haven't known that 'char' is supported.

When you (or someone other wise enough) have time, can we get full list of datatypes and their usage in Reference?
Thanks again :-)
PS4 - Titan2/Titan1 - Xim4 / XIM Apex - Logitech G502 Hero / Logitech G13 Advanced Gameboard / Logitech G213 Keyboard - DS4v2
User avatar
Shaag7
Command Sergeant Major
Command Sergeant Major
 
Posts: 121
Joined: Mon Sep 14, 2015 3:03 pm
Location: EU

Re: GPC2 Language Reference

Postby roidman » Sat Jan 27, 2018 8:12 pm

For noobs, where can we find references to simple things? I am having trouble with declaring a variable and then inverting it under a condition.

bool a = false;

if(....)
a=!a

does not work... I looked at the language reference and did not see anything there. I am surprised and impressed that some of you can do such in depth coding in this language, at this stage of documentation.

Edit: Declaring as int works, still it would be nice to get that documentation soon.
User avatar
roidman
Sergeant Major
Sergeant Major
 
Posts: 71
Joined: Tue May 05, 2015 7:21 pm

Re: GPC2 Language Reference

Postby Sillyasskid » Sat Jan 27, 2018 10:57 pm

roidman wrote:bool a = false;

if(....)
a=!a

does not work...


I'm assuming you initialized bool a. inside the main code block, like so:
Code: Select all
main{
bool a = FALSE;
if(...)
a=!a;
}

If this is correct?, then of course its not going to work lol. Because the main code block gets called every ms. and bool a is continuously going to be called, and assigned FALSE.

Here are a few ways to get around this.

You could make "bool a", a global variable instead, This is the ideal solution.
Example 1
Code: Select all
bool a = FALSE;
main{
if(...)
a=!a;
}


Another solution, would be to just declare bool a by it self. Don't assign it a value. when you place it in the main code block.
Example 2
Code: Select all
main{
bool a;
if(...)
a=!a;
}


A third solution, which is equivalent to the above example. Is to declare your variable as a static bool. A static type can be assigned a value, and you wont have to worry about the value being re-assigned every time the main code block is called. As it will remember its last state.
Example 3
Code: Select all
main{
static bool a = FALSE;
if(...)
a=!a;
}

although just keep in mind, static bool a = FALSE; is equivalent to just declaring bool a; by it self.
A static bool variable initialized in the main code block is beneficial, if you want to assign the value TRUE; So If you want to assign it FALSE, just stick with Example 2.
User avatar
Sillyasskid
Captain
Captain
 
Posts: 574
Joined: Sat May 14, 2016 3:07 am

Re: GPC2 Language Reference

Postby captain » Tue Oct 30, 2018 6:18 pm

How do you do subroutines? I tried putting multiple combo_run in my main() and it BORKED the TitanTWO to hell. I mean seriously frakked it up. I had to HARD RESET the damn thing with two-button-holds and power cycling BS just to get it to work again at all. :-(

Here's what I'm talking about:

main {
while (keepalive = TRUE){
combo_run(DOSHIT);
combo_run(DOBETTERSHIT);
}
}
Last edited by captain on Tue Oct 30, 2018 6:21 pm, edited 1 time in total.
User avatar
captain
Staff Sergeant
Staff Sergeant
 
Posts: 12
Joined: Sat Oct 27, 2018 6:16 pm

PreviousNext

Return to Tutorials and FAQs

Who is online

Users browsing this forum: No registered users and 43 guests