Page 1 of 1

Posting Code into Forum Topics

PostPosted: Wed Jun 22, 2016 4:26 pm
by UK_Wildcats
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 15031 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 15031 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 15031 times

Re: Posting Code into Forum Topics

PostPosted: Wed Jun 22, 2016 8:55 pm
by bonefisher
Great sticky!

Re: Posting Code into Forum Topics

PostPosted: Wed Jun 22, 2016 10:11 pm
by UK_Wildcats
Thank you. I wanted to make it easier for people to post code without losing the formating and making for long posts.

Re: Posting Code into Forum Topics

PostPosted: Wed Jun 22, 2016 10:22 pm
by The_Rabid_Taco
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.

Re: Posting Code into Forum Topics

PostPosted: Mon Jun 27, 2016 11:45 am
by J2Kbr
bonefisher wrote:Great sticky!

+1

Re: Posting Code into Forum Topics

PostPosted: Tue Jul 12, 2016 6:09 pm
by Massacre
Code: Select all
Thank you

Re: Posting Code into Forum Topics

PostPosted: Tue Jul 12, 2016 6:24 pm
by J2Kbr
"Thank you" is not a GPC keyword, you should comment then:
Code: Select all
/* Thank you */

lol :innocent_smile_1:

Re: Posting Code into Forum Topics

PostPosted: Tue Jul 12, 2016 8:21 pm
by UK_Wildcats
Or like this. LOL

Code: Select all
// Thank you