Commenting.
#1
Alright, it's been awhile since I've wrote a tutorial. Just feel free to rate it depending on how helpful this first post is. :P

About commenting...
So... commenting! In RPG Maker XP/VX, a comment's (whether as an event command or a line/block in your code) main purpose is to serve as a note to event system developers, scripters, game developers or pretty much anyone who wishes to view the source code to whatever (projects/events/scripts).

Commenting in events...
Not much you really need to do here, eventers. Simply look for the "comment" event command in the list of commands, type out your comment and that's pretty much it.

Commenting in scripts...
Single Line
The Ruby Single Line comments begins with # and ends at the end of the line. This is pretty much ignored by the interpreter. This doesn't necessarily have to occur at the beginning of the line either, it can occur anywhere within the line.
Code:
# This is a comment.

print "Hello, world!" # Does a "print" box saying hello world.

Multi Line
A multi-line comment (or comment block if you want to call it that) begins with the =begin token and ends with the =end token. They should start at the beginning of the line and be the only thing on them. Anything between those two tokens would be ignored by the interpreter.
Code:
=begin
Any number of lines may be written here.
They will be ignored.
On that note...
PIZZA! *NOMS*
=end

Usage in Scripting...
It's usually good form to put these before methods and classes as well as any piece of code that might be complex, vague, unclear or just plain confusing.

Commenting Practices...
Comments should be used to give information or annotate difficult code/commands. Comments that says what the next line of pretty straightforward code does would just add clutter and are just unnecessary if they're stating the obvious. Also to note, make sure the comments in your code/system are meaningful and helpful to other developers or users. That would really help. :P

This is to anyone who's new to scripting or getting into making some complex event systems. Use comments, be it in the form of an event command or a script line. Some users (well, like a fool, I used to do this when I was making systems) tend to make their systems and their scripts comment-less believing that commenting wouldn't be needed or they would write vague comments which isn't going to help them in the long-run. I mean, do you really believe you'd be able to remember exactly what you were thinking when you look back on your stuff in like a year or so from now? I highly doubt it. :P

Let the comments filter through your event code or script code and you'll be a much happier... whatever you are. Just remember to use single line comments for quick notes/tricky parts in your code and multiple lines for a set of functions that need to be described in greater depth.

Thanks for reading! :D
Reply }
#2
Never thought I'd see a commenting tutorial, lol. Good work Punk.
Reply }




Users browsing this thread: 1 Guest(s)