Posting Code into Forum Topics

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

Posting Code into Forum Topics

Postby UK_Wildcats_Fans » Wed Jun 22, 2016 4:26 pm

I have recently seen a lot of people posting code directly into topics. The code is more difficult to read, follow and it loses the GPC scripting format when you copy and paste it. Below is an example of how the code looks using both methods.

Copying and pasting code using the "GPC Code" option
Code: Select all
define TURBO_BUTTON = PS4_CIRCLE;

int doubletap_stage = 0;
int doubletap_timing;
int turbo_toggle = FALSE;

main {
    if(doubletap_stage == 0) {
        if(get_val(TURBO_BUTTON)) doubletap_stage = 1;
    } else if(doubletap_stage == 1) {
        if(!get_val(TURBO_BUTTON)) { doubletap_timing = 0; doubletap_stage = 2; }
    } else if(doubletap_stage == 2) {
        if(get_val(TURBO_BUTTON)) { doubletap_stage = 1; turbo_toggle = !turbo_toggle; }
        doubletap_timing = doubletap_timing + get_rtime();
        if(doubletap_timing > 100) doubletap_stage = 0;
    }
    if(turbo_toggle) {
        combo_run(TurboButton);
    }
}

combo TurboButton {
    set_val(TURBO_BUTTON, 100);
    wait(40);
    set_val(TURBO_BUTTON, 0);
    wait(30);
    set_val(TURBO_BUTTON, 0);
}


Copying and pasting directly into the topic.

define TURBO_BUTTON = PS4_CIRCLE;

int doubletap_stage = 0;
int doubletap_timing;
int turbo_toggle = FALSE;

main {
if(doubletap_stage == 0) {
if(get_val(TURBO_BUTTON)) doubletap_stage = 1;
} else if(doubletap_stage == 1) {
if(!get_val(TURBO_BUTTON)) { doubletap_timing = 0; doubletap_stage = 2; }
} else if(doubletap_stage == 2) {
if(get_val(TURBO_BUTTON)) { doubletap_stage = 1; turbo_toggle = !turbo_toggle; }
doubletap_timing = doubletap_timing + get_rtime();
if(doubletap_timing > 100) doubletap_stage = 0;
}
if(turbo_toggle) {
combo_run(TurboButton);
}
}

combo TurboButton {
set_val(TURBO_BUTTON, 100);
wait(40);
set_val(TURBO_BUTTON, 0);
wait(30);
set_val(TURBO_BUTTON, 0);
}

Please notice that the indentation is completely removed when you directly post in the topic.

This is Quick Reply, which is great for quick textual replies. If you want to do more, you have to use "POSTREPLY" or use "Full Editor" from the Quick Reply box.
Quick Reply.jpg
Quick Reply.jpg (2.74 KiB) Viewed 6916 times


You must use "POSTREPLY" or "Full Editor" in order to use full posting options including "GPC Code".

Here are all options available when using "POSTREPLY" or "Full Editor"
Full Editor.jpg
Full Editor.jpg (50.03 KiB) Viewed 6916 times


Here are the steps to post code directly into a topic using the "GPC Code" option.
1. Click "POSTREPLY" button or
1. Click "Quick Reply" button and then click "Full Editor"
2. Type in your message.
3. Place cursor where you want to paste code
4. Click "GPC Code" button
5. Paste your code


NOTE: To post code correctly, your cursor MUST be between the brackets and shown below.
brackets.jpg
brackets.jpg (16.5 KiB) Viewed 6916 times
User avatar
UK_Wildcats_Fans
Brigadier General
Brigadier General
 
Posts: 2109
Joined: Thu Jan 08, 2015 6:53 pm
Location: San Diego, California USA

Re: Posting Code into Forum Topics

Postby bonefisher » Wed Jun 22, 2016 8:55 pm

Great sticky!
bonefisher
Lieutenant General
Lieutenant General
 
Posts: 5363
Joined: Thu Jan 29, 2015 10:49 am

Re: Posting Code into Forum Topics

Postby UK_Wildcats_Fans » Wed Jun 22, 2016 10:11 pm

Thank you. I wanted to make it easier for people to post code without losing the formating and making for long posts.
User avatar
UK_Wildcats_Fans
Brigadier General
Brigadier General
 
Posts: 2109
Joined: Thu Jan 08, 2015 6:53 pm
Location: San Diego, California USA

Re: Posting Code into Forum Topics

Postby The_Rabid_Taco » Wed Jun 22, 2016 10:22 pm

Great idea, took me a few posts to get it right. Some of them become really hard to read. Should help people out a lot.
User avatar
The_Rabid_Taco
Major
Major
 
Posts: 1067
Joined: Wed Mar 16, 2016 6:04 pm
Location: Pensacola, FL

Re: Posting Code into Forum Topics

Postby J2Kbr » Mon Jun 27, 2016 11:45 am

bonefisher wrote:Great sticky!

+1
ConsoleTuner Support Team
User avatar
J2Kbr
General of the Army
General of the Army
 
Posts: 18128
Joined: Tue Mar 18, 2014 1:39 pm

Re: Posting Code into Forum Topics

Postby Massacre » Tue Jul 12, 2016 6:09 pm

Code: Select all
Thank you
User avatar
Massacre
Sergeant Major
Sergeant Major
 
Posts: 95
Joined: Wed Jul 06, 2016 1:55 am
Location: Oklahoma

Re: Posting Code into Forum Topics

Postby J2Kbr » Tue Jul 12, 2016 6:24 pm

"Thank you" is not a GPC keyword, you should comment then:
Code: Select all
/* Thank you */

lol :innocent_smile_1:
ConsoleTuner Support Team
User avatar
J2Kbr
General of the Army
General of the Army
 
Posts: 18128
Joined: Tue Mar 18, 2014 1:39 pm

Re: Posting Code into Forum Topics

Postby UK_Wildcats_Fans » Tue Jul 12, 2016 8:21 pm

Or like this. LOL

Code: Select all
// Thank you
User avatar
UK_Wildcats_Fans
Brigadier General
Brigadier General
 
Posts: 2109
Joined: Thu Jan 08, 2015 6:53 pm
Location: San Diego, California USA


Return to Tutorials and FAQs

Who is online

Users browsing this forum: No registered users and 4 guests