GPC2 language reference

GPC2 script programming for Titan Two. Code examples, questions, requests.

Re: GPC2 language reference

Postby pablosscripts » Fri Sep 09, 2016 3:20 am

No luck, converting the type didn't work:

Original:

Code: Select all
random_tee_bag = rand(70, 100);


Still doesn't work:

Code: Select all
random_tee_bag = rand(70.00, 100.00);
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 PaulaTheKoala » Fri Sep 09, 2016 5:22 am

pablogroup wrote:No luck, converting the type didn't work:

Original:

Code: Select all
random_tee_bag = rand(70, 100);


Still doesn't work:

Code: Select all
random_tee_bag = rand(70.00, 100.00);


The rand function doesn't take any arguments:

Image

It returns a value between 0 and 32767. If you want to get a random number between a certain range, you'll need to create and use your own function:

This will return a number between 0 and the number you specify:

Code: Select all
int random(int maximum)
{
    return ((int) rand() % (maximum + 1));
}


This will return a number between the ranges you specify.

Code: Select all
int random(int minimum, int maximum)
{
    return ((int) rand() % ((maximum + 1) - minimum)) + minimum;
}


If you want to use both of these functions in a script, one of the functions will need to be renamed, AFAIK function overloading isn't allowed in C.
User avatar
PaulaTheKoala
Command Sergeant Major
Command Sergeant Major
 
Posts: 131
Joined: Wed Aug 26, 2015 3:45 am

Re: GPC2 language reference

Postby pablosscripts » Fri Sep 09, 2016 6:05 am

PaulaTheKoala wrote:The rand function doesn't take any arguments:

Image


How do you get that hoverover to appear?

PaulaTheKoala wrote:This will return a number between the ranges you specify.

Code: Select all
int random(int minimum, int maximum)
{
    return ((int) rand() % ((maximum + 1) - minimum)) + minimum;
}


If you want to use both of these functions in a script, one of the functions will need to be renamed, AFAIK function overloading isn't allowed in C.


Thank you!! I finally got my auto-t-bag script to work:

Code: Select all

int random_tee_bag;

    random_tee_bag = random(70, 100);
    if(get_val(RELOAD) && event_actived(CROUCH)) {
       tee_bag_flag = TRUE;
    }
    if(get_val(RELOAD) && tee_bag_flag) {
        walk_flag = FALSE;
        combo_run(TeeBag);
    } else if(event_resting(RELOAD)) {
        tee_bag_flag = FALSE;
    }

combo TeeBag {
    set_val(CROUCH, 0);
    wait(random_tee_bag);
    set_val(CROUCH, 100);
    wait(random_tee_bag);
}

int random(int minimum, int maximum)
{
   return ((int) rand() % ((maximum + 1) - minimum)) + minimum;
}

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 PaulaTheKoala » Fri Sep 09, 2016 6:26 am

pablogroup wrote:
PaulaTheKoala wrote:The rand function doesn't take any arguments:

Image


How do you get that hoverover to appear?

PaulaTheKoala wrote:This will return a number between the ranges you specify.

Code: Select all
int random(int minimum, int maximum)
{
    return ((int) rand() % ((maximum + 1) - minimum)) + minimum;
}


If you want to use both of these functions in a script, one of the functions will need to be renamed, AFAIK function overloading isn't allowed in C.


Thank you!! I finally got my auto-t-bag script to work:

Code: Select all

int random_tee_bag;

    random_tee_bag = random(70, 100);
    if(get_val(RELOAD) && event_actived(CROUCH)) {
       tee_bag_flag = TRUE;
    }
    if(get_val(RELOAD) && tee_bag_flag) {
        walk_flag = FALSE;
        combo_run(TeeBag);
    } else if(event_resting(RELOAD)) {
        tee_bag_flag = FALSE;
    }

combo TeeBag {
    set_val(CROUCH, 0);
    wait(random_tee_bag);
    set_val(CROUCH, 100);
    wait(random_tee_bag);
}

int random(int minimum, int maximum)
{
   return ((int) rand() % ((maximum + 1) - minimum)) + minimum;
}



Glad to help. Also when you use a left parenthesis as seen in the picture, it should cause the details about the function to show, if it doesn't you may have to hit backspace and try again.
User avatar
PaulaTheKoala
Command Sergeant Major
Command Sergeant Major
 
Posts: 131
Joined: Wed Aug 26, 2015 3:45 am

Re: GPC2 language reference

Postby pablosscripts » Fri Sep 09, 2016 6:28 am

Great! I just tested it and every single time I tried a new function I had to press the back space and try again. It must need to cache it the first time or something.
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 bonefisher » Fri Sep 09, 2016 9:55 am

Once you hook up to the Titan 2 which the whole world is going to change for you because some things are not seen til you hook up! Take a deep breath pablogroup and release. lol!
bonefisher
Lieutenant General
Lieutenant General
 
Posts: 5413
Joined: Thu Jan 29, 2015 10:49 am

Re: GPC2 language reference

Postby pablosscripts » Fri Sep 09, 2016 10:09 am

bonefisher wrote:Once you hook up to the Titan 2 which the whole world is going to change for you because some things are not seen til you hook up! Take a deep breath pablogroup and release. lol!



haha I'm easily excitable. Let the hype flow through you bonefisher, you know you want to take a look at GPC2 code. You know you want it. Give in to temptation..!
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 bonefisher » Fri Sep 09, 2016 10:48 am

You know the greatest golf players never show there emotions even when they get that hole in one because it can turn around to get a triple bogie on the next hole because of being to excited. I'll just stay happy medium and await for the hole in one. lol!
bonefisher
Lieutenant General
Lieutenant General
 
Posts: 5413
Joined: Thu Jan 29, 2015 10:49 am

Re: GPC2 language reference

Postby pablosscripts » Fri Sep 09, 2016 10:49 am

bonefisher wrote:You know the greatest golf players never show there emotions even when they get that hole in one because it can turn around to get a triple bogie on the next hole because of being to excited. I'll just stay happy medium and await for the hole in one. lol!


Code: Select all
set_val(HYPE, 100);
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 » Fri Sep 09, 2016 9:33 pm

Sorry guys for let you all without proper answers here. But very glad to see you already figured out some questions raised here.

Tip: Press ctrl+space to list all GPC keywords.

Another tip: everything related to the input/output are fix32 (or accum) type. This is new for Titan Two and allow normalization of the input/output values with from 0.000000 to 100.000000%. Up to 6 decimal places, and resolution of 0.000015.
ConsoleTuner Support Team
User avatar
J2Kbr
General of the Army
General of the Army
 
Posts: 20323
Joined: Tue Mar 18, 2014 1:39 pm

Previous

Return to GPC2 Script Programming

Who is online

Users browsing this forum: No registered users and 147 guests