How to properly put your GML Code/Visual in a Forum Thread

Evanski

Raccoon Lord
Forum Staff
Moderator
Today's guide will be about how to properly put code in your forum thread,
I'm putting this in the programming forum because it will be easier for people who commit this crime to see it and learn how to create a thread properly.

If you would like a more serious and detailed tutorial please read this post by Frosty cat
(Posting code on the programming forum dos and donts)


NOTE:
At the time of this tutorial, Their is no way to convert GML Visual (drag&drop) to a plain text format,
if you are using GML Visual, Supplying a clean picture of the code is fine,
If on windows you can use (win)+shift+S, and select a part of your monitor to capture as an png that will be saved to the clipboard.
open paint or the like, and ctrl+v on the canvas, then save as a png,
you can upload this to the forum using the img icon, next to the chain link and </> icons.
Alternatively upload the png to imgur and supply the image url, (right click> copy image address) instead of uploading the png.
When using imgur sometimes you will need to get the image address twice as the first time will give a bad link
HOWEVER
If you are not using gml visual, PLEASE DO NOT ATTACH A PHOTO OF YOUR CODE, COPY PASTE IT IN CODE BLOCKS!!!
Often then not, the image of your code will be hard to see as well as prevent people from coping the code to test the errors for themselves.
No one is going to steal your code, so don't worry about that please.


DO NOT PUT YOUR CODE AS PLAIN TEXT
if you do, You make the code harder to read for someone trying to help
as well as get errors like:

Emojis where characters are meant to be:
if (bad_at_putting_code)

{


thread = (bad;)


}

Incorrect formatting and spacing:
if (startmovie_stage == 2){
if !audio_is_playing(snd_sfx_startmovie_hiphop){
audio_play_sound(snd_sfx_startmovie_hiphop,1,false);
startmovie_stage = 3;
}
}

Why does this happen?
This is because the forum is considering your code as text such as this you are currently reading, and formatting it as such, thus the errors.
This is why code blocks are important to use and helps you help us help all

DO
STEP 1:

Untitled.png
post.png
Head on over to the programming section, and slap that post thread button

STEP 2:
post code.png
Make sure to give your post a prefix that matches your post, ie if you are using GameMaker(latest) or Legacy, HTML5, Opera gx ...ect
Give it a good title so people get a good idea about what your issue is, make it sort and sweet but descriptive
then in the bar go over to the three ... and select code from the drop down

STEP 3:
code.png
Make sure the Language is set to GML
and copy paste your code into the box.
feel free to always check if your code is in a code block by pressing the preview button

STEP 4:
format.png
Make sure your code is in between two [‎ CODE‎ ] blocks
make sure to explain your code, we don't know your garble of if statements, but don't over do it, not everyone here is slow,
after that Congratulations you can preview it as it would show, or post your new thread,
Happy coding and good luck on any problems in the future!


Addendum:
Do not use the inline code blocks
they make your code look worse then the broken unicode ones.
inline codes use the [ iC0de ] blocks
you need to use normal [ c0de ] blocks

Don't do this! Only villains do this!
if (bad_at_putting_code){
thread = (bad;)
}


with(obj_startmovie_skele){
other.skele_in_position = in_position;
}

if (skele_in_position) && (startmovie_stage == 1){
audio_play_sound(snd_sfx_startmovie_hiphop,1,false);
startmovie_stage = 2;
}

if (startmovie_stage == 2){
if !audio_is_playing(snd_sfx_startmovie_hiphop){
audio_play_sound(snd_sfx_startmovie_hiphop,1,false);
startmovie_stage = 3;
}
}

if (startmovie_stage == 3){
if !audio_is_playing(snd_sfx_startmovie_hiphop){
startmovie_stage = 4;
}
}

if (startmovie_stage == 4){
with(obj_startmovie_gengar){
image_speed = 1;
}
startmovie_stage = 5;
}

if (startmovie_stage == 5){
with(obj_startmovie_gengar){
other.gangar_speed = image_speed;
}

if (gangar_speed == 0){
audio_stop_sound(snd_mus_titlemovie);
alarm[1] = room_speed / 2;

with(obj_startmovie_skele){
draw_mouth = true;
image_index = 1;
}

startmovie_stage = 6;
}
}
 
Last edited:

Alexx

Member
Today guide will be about how to properly put code in your thread, Im putting this in the programming forum because it will be easier for people who commit this crime to see it and learn how to create a thread properly

DO NOT PUT YOUR CODE AS PLAIN TEXT
if you do you get errors like:

if (bad_at_putting_code)
{
thread = (bad;)
}

and improper spacing

DO
STEP 1:
View attachment 23233
Start by pressing the "Post new thread" button as shown

STEP 2:
View attachment 23234
Now if you have code to post, please press the "Insert" option and then select "Code" from the list.

STEP 3:
View attachment 23235
Now type your code in the box, make sure its in between the two
Code:
,
feel free to always check by pressing the preview button

STEP 4:
[ATTACH=full]23236[/ATTACH]
make sure to explain your code, we dont know your garble of if statements, but dont over do it, not everyone here is slow, after that Congratulations you can preview it as it would show, or post your new thread, Happy coding and good luck on any problems in the future!
Also, formatting text in red makes it difficult to read.
 

curato

Member
Good luck. This is one of those things like telling people to search or use the manual before posting a question, no matter how many times you say it they will do what they perceive as more convenient. This even though counter to their perception would make their life easier too.
 

Joe Ellis

Member
If you're posting GML, you probably also want to choose GML from the "Language" drop-down. It affects things like which keywords are highlighted. I've found that when posting more than one CODE block using the Insert widget, the first one defaults to GML, but after that, they default to General Code.
I always wondered why it does that. After quite a while I thought that it might be cus of people who post several code blocks are more likely to be posting stuff that's in a another language, like c++ for extensions. But I still don't really know why it does it. I would love to have it clarified by mods(@TsukaYuriko, @Nocturne, @chance, @etc.) :D
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
I always wondered why it does that. After quite a while I thought that it might be cus of people who post several code blocks are more likely to be posting stuff that's in a another language, like c++ for extensions. But I still don't really know why it does it. I would love to have it clarified by mods(@TsukaYuriko, @Nocturne, @chance, @etc.) :D
It does this because I haven't worked out how to stop it doing this. :(
 

Joe Ellis

Member
Ah, well at least that's cleared up ;D I no longer have to think it's being fair to people posting alot of c++ code, it is just a bug.
 

Evanski

Raccoon Lord
Forum Staff
Moderator
@Nocturne Should I update this post? It doesnt get a lot of use, but seeing as people are now posting in it and its finding its way back up, maybe it can be turned into an actually helpful topic?
 
It also helps to get into the practice commenting sections of your code ( e.g. state machines ) using ///,//, ( and etc. ) ...for single line comments, and /* .... */ for multiple line comment styles. This benefits not only the people who your trying to get help from who will understand what the meaning of your code from a glance the more complex it is, but also helps you as the person who wrote the code, so when your debugging it, you don't end up spending the needless time of reminding yourself every time what you were doing in that part of the listing. In fact when your program expands and becomes more complex, this is something you will have to do. So practicing the part of commenting your code no matter the size of the listings or functions in a listing that you define , even when they start small, not only helps you in the long run, but everyone who reads it who your trying to get help from on this forum.
 
NOTE:
At the time of this tutorial, Their is no way to convert GML Visual (drag&drop) to a plain text format,
if you are using GML Visual, Supplying a clean picture of the code is fine,
If on windows you can use (win)+shift+S, and select a part of your monitor to capture as an png that will be saved to the clipboard.
open paint or the like, and ctrl+v on the canvas, then save as a png,
you can upload this to the forum using the img icon, next to the chain link and </> icons.
Alternatively upload the png to imgur and supply the image url, (right click> copy image address) instead of uploading the png.
When using imgur sometimes you will need to get the image address twice as the first time will give a bad link
One can paste the image directly into a GMC post, skipping the app/save step. Definitely worth mentioning methinks.

(Imgur is still an option of course to share with others. I don't know if Imgur accepts pasting for posting, but also worth mentioning if so.)
 
Other than status posts and maybe Conversations, where can you not upload an image directly? This topic chiefly applies to the Programming subforum after all, eh? $;^ J Well, maybe in a newbie's first five posts or something...
 
Top