Learning Ruby -- Lesson 1: Setting up a Ruby Environment
In these lessons, I will be working with the official Ruby interpreter. However, if you'd rather work through RPG Maker, that is definitely possible and for that reason, I will tell you how to do both.
**I will use these notes for little "asides" that I have throughout the lessons. These will contain information that is not necessary in the learning process, and for the most part be more "techy" stuff.
Step 1: Download and Install the Interpreter
First, we will need the actual Ruby interpreter, in order to execute Ruby scripts that we create. You can head over to:
http://www.ruby-lang.org/en/downloads/
There are a few ways to install Ruby, however, if you are in a Windows environment, the easiest and most painless way is to use the RubyInstaller:
http://rubyinstaller.org/downloads/
The version you get isn't overly important. RPG Maker XP/VX use (I believe) version 1.8.4
If you plan to go beyond RPG Maker scripting, I would personally choose 1.9.3 (latest version)
Once you have downloaded rubyinstaller, run the installer.
IMPORTANT:
Ensure you have "Add Ruby executables to your PATH"
In this tutorial I will be mostly working with ruby from the command prompt, and this will help that process immensely.
I would suggest associating .rb/.rbw files with this interpreter (assuming this is the only interpreter you have installed). This will allow you to run ruby scripts by double clicking on them.
tk/tcl is NOT necessary for this tutorial. tk (toolkit) is the main GUI library for ruby, and I will not be teaching that. If you wish to learn to build GUI applications with ruby, I would advise learning tk: http://www.tkdocs.co...al/onepage.html
Step 2: Confirm Installation
Simply open up a command prompt
Go to Start > Program Files > Accessories > Command Prompt
or
Go to Start > Run
Type in "cmd" (without quotes)
Click ok
Once you have a command prompt open, type:
ruby -v
The output *should* be something similar to this:
ruby 1.9.3p0 (2011-10-30) [i386-mingw32]
The exact details may vary, but if ruby -v displays a message, then everything went correctly.
If you are in a Linux based environment, you could use your package manager to get ruby.
ex. Aptitude Package Manager
sudo apt-get install ruby
You could also download the source code, and compile it yourself:
http://www.ruby-lang.org/en/downloads/
Or, what I use is, RVM - the ruby version manager
http://beginrescueend.com/rvm/basics/
This program allows you to seamlessly use and install multiple ruby interpreters side-by-side,
follow the website's directions. If you need help, I can help walk you through it in more detail.
Then to verify everthing went well:
open a terminal, type:
ruby -v
The output *should* be something similar to this:
ruby 1.9.3p0 (2011-10-30) [i386-mingw32]
Step 1: Create a new Project
Open RPG Maker (XP or VX) and create a new project.
Step 2: Setup Scripts
Open the script editor (F11 or Tools > Script Editor), and then delete EVERY SINGLE SCRIPT.
IMPORTANT: In this tutorial, when I redirect output to the console I mainly use `puts`. Unfortunately, RPG Maker does not use a console, and puts will do nothing for you. To get around this, either replace puts with `p` this will redirect the output to a Windows Message box. Or, add this script to the script editor (above any tutorial code you write)
http://forum.chaos-p...hp?topic=7816.0
CREDITS AND THANKS to ForeverZer0 for this script.
And voila! We have a working ruby environment.
Compiled languages mean the code is translated into machine code, then stored for later execution.
Interpreted languages are compiled real-time (each line is translated or interpreted into machine code and executed on run-time).
So, this means compiled languages (naturally) are much, much faster than interpreted languages. However, with an interpreted language, one has room for a much higher level of abstraction and allow for much more dynamic code (ex. changing an objects functionality during run-time). This also means faster development.
As you can see, each have their ups and downs
Wait, that hardly seemed like a lesson....
Oh, I forgot to mention, this week you get a few small lessons to begin your journey into ruby :D
I will provide you with enough to get you thinking and prepared for next week.
0 Comments
Recommended Comments
There are no comments to display.
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now