Tutorial: Ruby Coding Environment Alternatives

Gump

War Veteran
Veteran
Joined
Mar 14, 2013
Messages
43
Reaction score
10
First Language
English
Primarily Uses
Introduction and Outline:
---------------------------------
This tutorial assumes you have a basic understanding of scripting, and that you have created at least a couple of your own scripts. If you are looking to learn the basics, I would recommend DP3's video series collection. Today we're going to examine the Ruby coding environment we all know and use. We're going to memorize some handy shortcuts and we're also going to compare multiple environments, the upsides and downsides of using one over the other.
 
RPG Maker VX Ace Environment:
---------------------------------
Lets begin by taking a quick look at the Included coding environment within RPG Maker VX ACE. Referred to in VX ACE as the "Script Editor" This is actually our coding environment, the place where we add and modify ruby code. There are other names and interpretations of this kind of environment, and the Ruby scripting within VX ACE is somewhat limiting in how it hides some core things from you (which is for your own good really unless you've been doing this for a long time) but for the sake of this tutorial, we will refer to this as our coding environment. So, here is the provided 'coding environment' that comes with VX ACE:


 
At a glance it looks good, but you may notice the window is not re-sizable. This was one of the things that bothered me early on, the fact that Despite the fact I had a 1080p monitor, I had to use this small window to script in. Its workable, I'll grant you that. Lets quickly go over some handy shortcuts that you will find yourself using in the VX ACE coding environment, 'currently active script' refers to whatever script is currently selected and is being edited:

  • CTRL+A = Select all (select every line of the currently active script)
  • CTRL+C = Copy (copy selection)
  • CTRL+V = Paste (paste selection)
  • CTRL+F = Find... (find text within currently active script)
  • CTRL+SHIFT+F = Find in all sections... (find text within all scripts. returns a list of results from all scripts)
  • CTRL+Q = Comment or Uncomment (disable) the selected lines of code
  • CTRL+D = Duplicate selection (appears and end of current line)
These are very useful, and whether or not you decide to code in an environment besides the VX ACE one you will end up using some of those shortcuts. I recommend burning them into your brain. Did I miss a shortcut that you think should be there? Let me know!
 
So lets talk limitations. You are editing in a small window. You have 81 visible characters on each line in that script window. I don't know about you but that seems inefficient to me. I'll grant you that the environment handles long lines just fine, but it can really make things feel clunky in my opinion when you only have 81 visible characters. Really if they would just make this window resizable and provide a dark theme for it, I would use it and never use a different environment. But that is not the reality that we have right now, maybe in a future version of RPG Maker. In the mean time, we can make do by utilizing other environments to our advantage.
 
We're going to take a look at two other options. Sublime Text 2 and Notepad++. Both of these editors provide support for the ruby syntax and full style preferences (colorization, theme etc) for the ruby syntax. Both of these editors also have their own upsides and drawbacks. We're going to take a look at these environments now. I want you to know that if you click the above image of the VX ACE environment, you'll get a full resolution visual of how big the VX ACE environment is. Click on these ones too and you'll also get that full resolution visual of just how big the environment is. I think you'll find the difference is like night and day.
 
Also it should be noted, my Desktop is 2688x1080 (I have a 15 inch monitor flipped vertically on the left side for 768x1024, and a 22 inch 1920x1080 monitor on the right). Both Notepad++ and Sublime text provide support for rocking multiple instances by simple drag-and-drop.
 
The Notepad++ Environment:

 
The Sublime Text 2 Environment:

 
Notepad++ Overview:
------------------------------------------------
Notepad++ comes with the ability to multi-instance. It can also load a 2nd tab for viewing of documents on the fly, with drag-and-drop functionality. Allow me to explain this. So in the notepad++ screenshot, on the right side you see a notepad++ window open that has two tabs, one on the left one on the right. Each one can hold a nest of open text documents (in this case ruby *.rb scripts).
The easiest way to take advantage of this is to:

  • open a bunch of scripts in notepad++
  • left click and drag one of the scripts out of the title bar and into empty space (over top of the text editing portion of the window, but not outside the window itself)
Dragging a document outside of the window will open the document in the new instance. If you follow the above directions properly a menu with 2 options will pop-up, select "move to other view".
 
Notepad++ does require some additional setup for comfortable use with ruby, this is basically the main drawback for Notepad++. Want a dark style like mine so you can code at 4am without burning your eyes on a white background? You'll have to mess around in the style configurator found within the Settings menu. If you're modifying an included theme, Run Notepad++ with admin privileges and modify the theme to your liking, then save and exit notepad and re-open it with normal user privileges. You're also going to want to modify some of notepad++'s default preferences, mainly you're going to want to make tabs  2 spaces instead of the default 4 so your scripts will have the standard ruby/vx ace indenting.
 
Sublime Text 2 Overview:
----------------------------------------------
Sublime comes with the ability to multi-instance with drag-and-drop functionality, a title bar for opening of multiple scripts like Notepad++. Simply drag an open text document from the title bar outside the Sublime window and it will open that document in a new instance of the editor. The main drawback for Sublime compared to notepad is the lack of an ability to have multiple views of documents open at once like Notepad++ can (see the right side of the notepad++ screenshot). Sublime makes up for this ability with some cool things.
 
Unlike Notepad++, sublime wont require you to set default tabbing to two spaces. It already handles that because it knows you're writing in Ruby. Unlike Notepad++ Sublime was programmed with the sole intention of being a convenient portable coding environment for a wide variety of languages. It also comes with something really cool that I must say, after using it a little bit really is a huge thing that helps me move around my scripts quicker. It has a virtual scroll bar. Look at the Sublime screenshots, and on the right side of each open instance of Sublime you'll see a small vertical visual scroll bar. You can clearly see the document in there. This thing reacts just like a scroll bar so you can grab the selected area and pull up and down. It really is a thing of beauty and does add a helpful feature (in my opinion) that the Notepad++ environment is lacking.
 
One downside to mention for Sublime is unlike notepad, it is not free. However, you can download the free version, and you do not get penalized for using it.
 
Chapter 2: Learn the ropes... Again!
----------------------------------------------
All environments outlined in this tutorial have their own upsides and downsides. Which environment you choose to use as a scripter really comes down to your personal preference and experience. I am currently using the Sublime environment, I previously worked a lot in the Notepad++ environment, and was stuck with the VX ACE environment beforehand. Depending on what you want or don't want in your environment, you might think Notepad++ is better, or Sublime. It really comes down to what you want.
 
Lets assume now that you've made the decision. You're going to use either Notepad++ or Sublime. You've made the choice to use a more efficient coding environment. Maybe something I said here convinced you, maybe something you said to yourself after reading something I said convinced you. Regardless, here is my setup guide for getting your started in your new environment. This will work with either Notepad++ or Sublime.

  • Install your preferred environment (Notepad++ or Sublime).
  • Navigate to your RPG Maker VX ACE game projects folder, or wherever you want to keep a folder that contains all your scripts. I prefer that location.
  • Make a new folder called "#SCRIPT WORK#" or something like that.
  • Drag the folder into your favorites in the left folder bar (Assuming Windows 7)
Now that you have the folder setup, note that you can quickly access the script folder from any explorer window. Simply open explorer to any folder location, and look in the favorites bar on the left side. You'll see your script folder. Now, open up your coding environment, be it Sublime or Notepad++. Setup your style preferences. Setup your theme and all that, get the editor looking the way you want it to.
 
Remember those hotkeys you burned in your mind earlier? The ones that the VX ACE coding environment uses? Now you're going to see why I told you to memorize those. If you didn't already, scroll up and burn them into your mind. Now that you got those burned into your head, here are some additional hotkeys to burn into your mind, for use with Sublime or Notepad++:

  • CTRL+A = Select ALL (select all data in the current open document)
  • CTRL+S = Save (save open document)
  • CTRL+C = Copy selected text (copy all selected text from the current open document)
Burn those in your mind. Burn them in. All burned and stuff? Okay, good. Now, start scripting. When I first started using an enviroment to script in that wasn't the vx ace ruby environment, the first thing I did was copy a script I was currently working on from vx ace over to the new environment, then saved it as a *.rb file in my new script folder. Do that now. Grab one of your recent scripts, copy/paste it into your new environment, then save it as a *.rb file.
 
Importing Code to VX ACE:
--------------------------------------
 
So, now you've made some cool script in your new scripting environment. Cool. Whats the fastest way to get it in your game? You might think its hard, but its really not. Remember those hotkeys you were supposed to burn in your mind earlier? Well this combination utilizes them. If you have a macro keyboard, you could setup a couple macros that manage this process. So anyway, this is how I import any script from my coding environment into VX ACE:

  • Open the script I want to import in my scripting environment, and make sure its active.
  • CTRL+A (select the entire script)
  • CTRL+S (save the entire script)
  • CTRL+C (copy the entire script)
  • Mouse movement: Click to focus VX ACE's scripting window
  • Select script area (old version of script in place)
  • CTRL+A (select the entire OLD script)
  • CTRL+V (paste the entire new script, OVERWRITING the old script)
  • Click Apply, ok (unless more scripts are waiting to be imported.
Its really a simple process once you've done it a couple times. You can do it quite fast really. You might think the CTRL+S (save the entire script) part is redundant but its not, its actually important. Often times when you decide to import a script its when you just finished working on it. So This combo has you covered whether or not the script actually needs to be saved. Burn the combo into your head. It will serve you well. Alternatively if you have a keyboard with macro keys, congratulations you win the internet. I have one too but I don't use it so there.
 
Thats all for this tutorial folks! Thanks for reading, happy scripting!
 
 
Tips & General Advice:
-----------------------------
This section will contain a bullet point list of general tips and advice for Notepad++ or Sublime Text 2 or VX ACE's built in coding environment. Things will be added here as people suggest tips or general advice that is suitable here, or as I think of things to add.

  • [TIP]: When making a new script, if it is going to consist of multiple scripts, make a new sub-folder for the project within your script folder, and name it something related to your new script. If you're making a new script thats just going to be 1 simple script in the end, it probably doesn't need a sub-folder. Keep your Scripts folder organized! Use relevant and easy to interpret filenames!
  • [DERP]: ALWAYS SAVE as *.rb when editing in notepad++ or sublime to properly preserve your work.
=====================================================================================================
ADDENDUM: Did I miss something that you think should be in here? Did you find a mistake? Did you see my missing 6 pack of beer? Please let me know! Thanks!
 
Last edited by a moderator:

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
I actually personally do it the reverse way, I save it to .txt afterwards... mainly because I'm a person that goes with continuous testing while I write a script... anyway, really nice and informational tutorial
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Did I miss a shortcut?
I use Control+Q a lot - select a block of text (even the whole script), and Ctl+Q will comment the entire thing. Repeat it and it'll uncomment it.


That scroll bar in Visual Sublime looks AMAZING!!! I am going to grab the trial and play with it JUST FOR THAT!


The only thing that would make other editors better is if they could just open the scripts from the rvdata2 file, instead of having to copy/paste from one to the other.
 

cabfe

Cool Cat
Veteran
Joined
Jun 13, 2013
Messages
2,353
Reaction score
2,549
First Language
French
Primarily Uses
RMVXA
Interesting reading. Even if I am a very average coder, I still have to tweak from time to time and having a correct environment is part of a success.

By the way, the Find in all sections shortcut I use is CTRL+SHIFT+F (without the ALT part). I'm on VX Ace too.
 

Dr.Yami

。◕‿◕。
Developer
Joined
Mar 5, 2012
Messages
1,003
Reaction score
757
First Language
Vietnamese
Primarily Uses
Other
I have been using Sublime Text for work for long time now :D However, I still use RMVXA Editor for RGSS3 lol, just too lazy to copy and paste over and over...
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Playing with Sublime Text 2 now. All I can say is this: whoever made those colour schemes needs to be taken out and shot!
 

Gump

War Veteran
Veteran
Joined
Mar 14, 2013
Messages
43
Reaction score
10
First Language
English
Primarily Uses
Shaz: How did I not know about CTRL+Q?! Added to the tutorial.

cabfe: Well I'll be damned.. This entire time I've been doing CTRL+SHIFT+ALT+F when in reality the shortcut is CTRL+SHIFT+F. Derp! Fixed the tutorial.

Thanks guys. :)
 
Last edited by a moderator:

Dr.Yami

。◕‿◕。
Developer
Joined
Mar 5, 2012
Messages
1,003
Reaction score
757
First Language
Vietnamese
Primarily Uses
Other
Do you know/have any good color scheme for Sublime Text? Want to have some new color scheme (for fun lulz)

Currently using Blackboard :D

 

Galenmereth

Retired
Veteran
Joined
May 15, 2013
Messages
2,248
Reaction score
2,158
First Language
English
Primarily Uses
N/A
Last edited by a moderator:

Gump

War Veteran
Veteran
Joined
Mar 14, 2013
Messages
43
Reaction score
10
First Language
English
Primarily Uses
I just use the Twlilight color scheme included with the program, and I'm using Sublime Text 2 specifically. A screenshot of this is in the Tutorial.

There are some damn nice skins out there. I just grabbed one that looks decent on a dark background and got to work. :)
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
I can't work with dark backgrounds. I'm using Eiffel, but Dawn is nice too.
 

Dr.Yami

。◕‿◕。
Developer
Joined
Mar 5, 2012
Messages
1,003
Reaction score
757
First Language
Vietnamese
Primarily Uses
Other
I can't work with light backgrounds >_<
 

TroyZ

The Slayer
Veteran
Joined
Jun 18, 2013
Messages
74
Reaction score
5
First Language
Indonesian
Primarily Uses
RMVXA
ahaa you miss one hidden shortcut, gump :D

try this on selected line in RGSS3 script editor : Ctrl + D

it'll directly duplicate the selected line into the line below it. but i seldom to use it actually hehehe :guffaw:

but i still love the notepad++ style actually B) but sublime text was looking cool actually :headshake:
 

Gump

War Veteran
Veteran
Joined
Mar 14, 2013
Messages
43
Reaction score
10
First Language
English
Primarily Uses
ahaa you miss one hidden shortcut, gump :D

try this on selected line in RGSS3 script editor : Ctrl + D

it'll directly duplicate the selected line into the line below it. but i seldom to use it actually hehehe :guffaw:

but i still love the notepad++ style actually B) but sublime text was looking cool actually :headshake:
Hmm, didn't know there was a built-in duplicate function, cool. Appears to duplicate the selection to the end of the same line. I couldn't see myself using this often, maybe sometimes. Added to the tutorial, thanks. :)
 

BadMinotaur

You can do it!
Veteran
Joined
Mar 13, 2012
Messages
260
Reaction score
115
First Language
English
Primarily Uses
RMVXA
I've seen others on here talk about using the 'require' method in their scripts. Is there a reason you couldn't just plunk a "require blah.rb" in the Script Editor and then edit your scripts externally without all of the copy and paste hassle?
 

TroyZ

The Slayer
Veteran
Joined
Jun 18, 2013
Messages
74
Reaction score
5
First Language
Indonesian
Primarily Uses
RMVXA
I've seen others on here talk about using the 'require' method in their scripts. Is there a reason you couldn't just plunk a "require blah.rb" in the Script Editor and then edit your scripts externally without all of the copy and paste hassle?
oh let me know how to use it :D

it sounds likely will shorten the editor's line xixixixi :D :D
 

Napoleon

Veteran
Veteran
Joined
Dec 29, 2012
Messages
869
Reaction score
97
First Language
Dutch
Primarily Uses
I've seen others on here talk about using the 'require' method in their scripts. Is there a reason you couldn't just plunk a "require blah.rb" in the Script Editor and then edit your scripts externally without all of the copy and paste hassle?
You mean like you have only 1 script with a bunch of "require" and then edit all files externally? That sounds nice. I really do not like the RM editor (always looking for that missing "end" for my if-statements :p ).
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
I've seen others on here talk about using the 'require' method in their scripts. Is there a reason you couldn't just plunk a "require blah.rb" in the Script Editor and then edit your scripts externally without all of the copy and paste hassle?
Ya, the process is straightforward. Here's a tutorial a script that does it


http://forum.chaos-project.com/index.php?topic=9938.0


Tried it, but didn't like it. Maybe cause I was using notepad++ and not sublime or a ruby IDE.
 
Last edited by a moderator:

Gump

War Veteran
Veteran
Joined
Mar 14, 2013
Messages
43
Reaction score
10
First Language
English
Primarily Uses
Whoa, I never thought of that. Doesn't look very hard either.

I did just macro key my combo though. So when done working on a script, I hit M1, then tab over to ace, and hit M2 and its inserted.

But still, using a require call instead just sounds a lot more efficient.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,854
Messages
1,016,998
Members
137,562
Latest member
tamedeathman
Top