I said I’d start some scripting tutorials for RGSS2 but before I get started I’m going to make the disclaimer that I’m a beginning scripter with this particular framework. I’m also a beginner when it comes to programming. Those facts aside, I think there’s something to be said for teaching what you’re learning to others. In this case, because I’m a beginner, I plan to explain RGSS2 in terms that other beginners can understand.

Before I get to the interesting stuff you can do with RGSS2, I’m going to start with some basic Ruby (and general programming) definitions. Grab a beverage and get comfortable, because this post is pretty long. To get any good at using RGSS2, though, you’ve got to understand a bit about Ruby and object-oriented programming, and that takes a fair amount of explanation.

Let’s start with the term “object-oriented programming.” Two of the most common programming types are object-oriented and procedural. Procedural is the easiest type to understand. In simple terms, in a procedural program the code is read and executed line by line, from the first line of code to the last. Eventing code in RMVX works, basically, how a procedural programming language would work, and is likely what most people reading this are familiar with.

This explanation is really oversimplified, but I’m using the concept of a procedural language to contrast with that of an object-oriented one. Object-oriented programming, on the other hand, is more like building a model with Legos and then motorizing the parts so your Lego model can roll across the carpet by itself or take some other type of action.

In object-oriented languages, the code you write models objects and how they interact. Descriptions for what types of properties and behavior those objects have are commonly called “classes.” Think of a class as a recipe for something. You use those classes to create the actual objects that you’ll be doing things to and with in your program.

I’ll use baking as an example. A chocolate chip cookie recipe is like a class. An actual cookie is an object of that class, or what is commonly called an “instance” of that class. Why the term instance? Well, just because you use a recipe for a chocolate chip cookie, every cookie can be different. Each cookie can have a slightly different shape, more or fewer chocolate chips, and is a single “instance” of a chocolate chip cookie.

In gaming terms, let’s say you have two slimes, ala Dragon Quest. Slime A is a single instance of the “slime” class and Slime B is another instance of the slime class. The slime class describes the stats and behavior that all slimes have, but if you’re in a battle, and you hit Slime A and not Slime B, then Slime A’s and Slime B’s actual hit points will be different. Each “instance” of a slime is different from every other “instance.”

The properties of a class are usually called something like “fields” or “class variables.” In Ruby they’re called class variables. The behavior that a given class can take is called a “method.” Using the slime example again, the slime’s class would have class variables like its hit points, its attack power, its defense that all slimes are supposed to have. Its behaviors, which are commonly called “methods,” would be attacking, running, defending and any special attacks, i.e. how the slime interacts with other objects (like characters) in the game.

So how does all this relate to RGSS2? RGSS2 is a big collection of “recipes,” or classes, that have properties (class variables) and behaviors (methods) pre-written for you. Just like recipes can be written in different spoken languages, the recipes in RGSS2 are written in the programming language Ruby. Ruby was introduced to the world originally in Japan back in 1995 by Yukihiro Matsumoto, and has since gained a pretty devoted following. One of Ruby’s most well-known frameworks is called Rails, which is designed for web development.

If you speak Ruby, you’ll be able to read and write your own RGSS2 classes that the RMVX engine can use as well as alter RGSS2’s basic recipes if you want. Okay, that’s enough theory for now. In my next post, I’m going to detail something that everybody who plays RPGs with combat is interested in: editing the basic battle formulas for your game.