Gw Temp

Menu

Tutorial - 'Commenting in RPG Maker 2000/3' by Mateui

An item about RPGMaker 2000 posted on

Blurb

Learn about the benefits of commenting in your code, different types of things you could use to help make your comments stand out, and places where you should include comments in Rm2k/3.

Body

Commenting in RPG Maker 2000/3
By: Mateui


This is a fairly simple tutorial on how to effectively use “comments” in RPG Maker 2000 or 2003. Everything is practically the same in both versions, only with one difference occurring in the 2003 version.

This tutorial will explain the benefits of commenting in your code, different types of things you could use to help make your comments stand out, and places where you should include comments.

What Are Comments?
Basically, comments are messages scattered throughout your code (or events) that explain what’s going on. They can also be used to effectively separate sections of code in your events, to make the whole event more readable.

(In Rm2k/3 the Comment Command can be found on the third page, near the bottom right of the page, right above the “Game Over” command. It should say “Insert Comment” or something of that nature.)

When to Add Comments
Generally, you should add comments as you add commands in your events. Try to do them as you go along, because if you try to go back later to comment, you may be confused as to what the section of code is referring to or doing.

Also, if you ever need to go back or refer to previous sections of code (commands) in your event, instead of trying to figure out what the commands are doing by interpreting them, the comments will tell you themselves. This will save you a lot of time in the long run.

Where to Add Comments
Specific places where you should comment are:

- Right at the beginning of the event. This comment should tell you what the whole event will accomplish or do. For instance, if the event is used to calculate damage in a CBS, the comment may look like this: “This event is used to calculated damage in the CBS. It randomizes a number based on some factors, deals damage to the enemy, and then shows a graphical representation of the damage (via Pictures)” Although that command is fairly long words-wise, it really helps you to figure out what the code will do. Even writing this comment before you actually place some commands will help you, as you have already established the process that the event will follow.

- Right before a fork condition that is used to figure out which key was pressed (Left, Right, Down, Up, Enter, Esc, Shift, etc..) This comment should say which key the fork condition will wait for before it is activated. If the Fork Condition is activated by the down key, you may use this comment: “///////////// (DOWN)”. This will make it easier later on to tell what keys the forks wait for. It’s simpler to know by the comment, than having to find out what “IF Cursor Input = 1” means.

- To separate sections of code at some places, such as before Fork Conditions, Enter Password, etc.

Comments: Rm2k Vs. Rm2k3
As I mentioned at the outset, there is only really one difference in the two versions of RPG Maker. The difference is that in Rm2k3, the first line in your comment will be colored in green, making the comment stand more out than the Rm2k version, where that comments are left in the same color as the rest of the commands.

Making Comments Stand Out

I will show you a screenshot of code with comments in it, and another screenshot of the same code without any comments.

(Alright. It’s not a screenshot – I typed out words.. because I was having some trouble with not being able to actually read the words in the screenshot I first took. It still looks authentic. :D)

There are many ways that people may comment in their events, this is only how I do it. Feel free to experiment with commenting to find out a way that works best for you. The purpose of these two pictures is to show you that commenting is beneficial.

Here is the first screenshot. No comments whatsoever. Can you try to figure out what the event and coding does? It’s pretty hard, and takes some time.



And here is the improved version, this time with comments. Now can you more clearly understand what’s going on?



Yes. Commenting actually does help, not only in understanding the code, but also in clarity.


Closing Words:

Commenting can be done many ways – it’s like a personal thing, because most times you’ll be looking at the code yourself. Sometimes, however, you’ll need to let someone else help you with coding your events – comments will help you in this area.

Experiment with commenting yourself, with the idea of making the coding more clearer and readable.

Good luck!



- Mateui