WARNING: I DISTRIBUTE BETA-QUALITY SOFTWARE IN THIS THREAD. BACKUP YOUR GAME BEFORE TRYING OUT THIS TUTORIAL.
How to set up your RMXP project to use .rb files in less than 15 minutes.
What is it and why would you want to do it
If you are a serious scripter, you know how annoying the integrated SciTE editor can be. It's definitely not as horrible as the event system, but it is still a serious pain to use.
This tutorial will basically allow you to stop using the RMXP scripts database, and use separate .rb files instead. It won't involve boring repetitive work to export the database, and unless you're using a script that is known not to work (the only one I know right now is the auto fullscreen script) you won't ever use the scripts database again.
There are many benefits:
- You can use a better editor that will make the bundled SciTE editor look like a joke
- It is easier to backup, to collaborate, and to try out things
- Edit your scripts from the network: use one computer to code, the other to test. It's must faster this way, and if you're like me and prefer using an editor that is only available on OS X or Linux, you can use it with RMXP.
If these things do not sound like actual benefits for you, then you should not follow this tutorial.
How to do it
1. Backup the folder of your project. This thing is not supposed to cause any damage, but by following this tutorial you are basically beta-testing my software. If you fail to backup your project, it will be your own fault if something goes horribly wrong.
2. Open the scripts database in your RMXP project: we'll make sure that the filenames will be exported cleanly.
In a default project where you have not edited any script, it will be the case.
However, it you added things like visual separators (for example an empty line, or a ligne of underscores), you'll end up with files named __________.rb or simply .rb. Make sure that the scripts you added use only letters, numbers, and spaces. (Spaces will be converted to underscores automatically to keep filepaths simple)
3. Download this file: scriptdb2rbfiles.exe v.1.0 BETA. I know, it's huge for what it is - about 1.5MB. That's the price of convenience. Copy it to your project folder
4. Open a command prompt: type WIN+R (or start menu > run), type 'cmd' then Enter.
Let's pretend that your project, Final Tales of the Legend of DBZ versus Naruto Championship Edition Ex Plus Alpha, is located at E:\RMXP\Projects\Final Tales\
You'd issue the following commands:
If nothing was displayed, then everything went right. If an error appears, read it, it may be explicit enough for you to troubleshoot it by yourself.
We will assume that everything went right.
5. This is your last chance to backup if you were foolish enough to skip this step
6. In your script database, delete ABSOLUTELY EVERY SCRIPT, except for the last one which RMXP won't let you delete. Remame it "Import", and replace its contents by the following:
7. Run your game. It should work. Test everything you can think of testing to make sure it works. If it doesn't and you can't figure out the problem, well, you have a backup, right?
Working with .rb files
So now that it works, what should be your new, improved workflow?
Modifying scripts
All your scripts are in the newly-created Scripts folder. You can edit them here with any text editor.
Adding scripts
To add a script, create a .rb file in the Scripts folder, then, in Scripts/import_all_in_original_order.rb , add a require statement in the position you want your script loaded.
Sorting your scripts into folders
Create subfolders in Scripts, then add each folder to the only scripts left in your RMXP scripts database. Let's say you have created scripts/orignal , scripts/final_tales_battlesystem , scripts/final_tales_menusystem . You can simply add folder by adding these lines in the import script :
Even if you use many folders, no two scripts should have the same filename. (There are workarounds, but I'm trying to give you the easiest method in this tutorial, not the most elegant.)
Using a better editor
Now, leaving SCiTE behind just to use Notepad.exe wouldn't be much of an upgrade. Here are a few editors you may want to look into:
- FreeRide is a free integrated development environment (IDE) for Ruby, written in Ruby itself. If you don't know what would suit you, try this one.
- If an IDE is too bulky for you, try Syn text editor (open-source)
- If even that one is too much for you, you can try Context or jEdit
- My favorite is TextMate (€40). It is only available for Mac Os X.
Using source control
This is way beyond the scope of this tutorial, but I recommend you try it if you don't work alone. It may require effort to learn, but it makes collaboration painfully simple. Actually, the .exe you've downloaded comes from the SVN repository of our project. To learn more, I recommend the book "Version Control with Subversion". The book is free to read online. You can find the whole book one one huge HTML page or as others formats such as PDF.
Scripts that don't work
A minority of scripts may not work for some reason. You can still use them by following these two steps :
1. Move the list of imports to the database. In the only script, remove the require line, keep the $: << './Scripts/' lines, then add the contents of import_all_in_original_order.rb then delete this file
2. Cut the list in 2 scripts in the database, adding the incompatible scripts where you need them
The following scripts or snippets are known to require this method:
- Auto full-screen
About the script scriptdb2rbfiles
This script is developped for another project. The current version is 1.0 beta. If people are interested in this tutorial, I will post updates to this script here.
The source of the exe is available. It was made into an .exe using rubyscript2exe.
I recommend you don't redistribute this script because it is beta quality, and in the RM world once beta-quality software is distributed it will never disappear even when updates are released. Please wait for the stable version before redistributing. In the meantime, please link here if you want to distribute the last version (new versions will appear there).
Of course, absolutely no credit is required or expected if you use this. We'd prefer to hear about your experience using this script than to get credit.
How to set up your RMXP project to use .rb files in less than 15 minutes.
What is it and why would you want to do it
If you are a serious scripter, you know how annoying the integrated SciTE editor can be. It's definitely not as horrible as the event system, but it is still a serious pain to use.
This tutorial will basically allow you to stop using the RMXP scripts database, and use separate .rb files instead. It won't involve boring repetitive work to export the database, and unless you're using a script that is known not to work (the only one I know right now is the auto fullscreen script) you won't ever use the scripts database again.
There are many benefits:
- You can use a better editor that will make the bundled SciTE editor look like a joke
- It is easier to backup, to collaborate, and to try out things
- Edit your scripts from the network: use one computer to code, the other to test. It's must faster this way, and if you're like me and prefer using an editor that is only available on OS X or Linux, you can use it with RMXP.
If these things do not sound like actual benefits for you, then you should not follow this tutorial.
How to do it
1. Backup the folder of your project. This thing is not supposed to cause any damage, but by following this tutorial you are basically beta-testing my software. If you fail to backup your project, it will be your own fault if something goes horribly wrong.
2. Open the scripts database in your RMXP project: we'll make sure that the filenames will be exported cleanly.
In a default project where you have not edited any script, it will be the case.
However, it you added things like visual separators (for example an empty line, or a ligne of underscores), you'll end up with files named __________.rb or simply .rb. Make sure that the scripts you added use only letters, numbers, and spaces. (Spaces will be converted to underscores automatically to keep filepaths simple)
3. Download this file: scriptdb2rbfiles.exe v.1.0 BETA. I know, it's huge for what it is - about 1.5MB. That's the price of convenience. Copy it to your project folder
4. Open a command prompt: type WIN+R (or start menu > run), type 'cmd' then Enter.
Let's pretend that your project, Final Tales of the Legend of DBZ versus Naruto Championship Edition Ex Plus Alpha, is located at E:\RMXP\Projects\Final Tales\
You'd issue the following commands:
Code:
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\YourNameHere>e:
E:\>cd E:\RMXP\Projects\Final Tales
E:\RMXP\Projects\Final Tales>scriptdb2rbfiles.exe Data\Scripts.rxdata Scripts
E:\RMXP\Projects\Final Tales>
If nothing was displayed, then everything went right. If an error appears, read it, it may be explicit enough for you to troubleshoot it by yourself.
We will assume that everything went right.
5. This is your last chance to backup if you were foolish enough to skip this step
6. In your script database, delete ABSOLUTELY EVERY SCRIPT, except for the last one which RMXP won't let you delete. Remame it "Import", and replace its contents by the following:
Code:
# Add ./Scripts/ to list of folders where you can require files.
# Use forward slashes
$: << './Scripts/'
require 'import_all_in_original_order.rb'
7. Run your game. It should work. Test everything you can think of testing to make sure it works. If it doesn't and you can't figure out the problem, well, you have a backup, right?
Working with .rb files
So now that it works, what should be your new, improved workflow?
Modifying scripts
All your scripts are in the newly-created Scripts folder. You can edit them here with any text editor.
Adding scripts
To add a script, create a .rb file in the Scripts folder, then, in Scripts/import_all_in_original_order.rb , add a require statement in the position you want your script loaded.
Sorting your scripts into folders
Create subfolders in Scripts, then add each folder to the only scripts left in your RMXP scripts database. Let's say you have created scripts/orignal , scripts/final_tales_battlesystem , scripts/final_tales_menusystem . You can simply add folder by adding these lines in the import script :
Code:
$: << './Scripts/'
$: << './Scripts/original/'
$: << './Scripts/final_tales_battlesystem/'
$: << './Scripts/final_tales_menusystem/'
Even if you use many folders, no two scripts should have the same filename. (There are workarounds, but I'm trying to give you the easiest method in this tutorial, not the most elegant.)
Using a better editor
Now, leaving SCiTE behind just to use Notepad.exe wouldn't be much of an upgrade. Here are a few editors you may want to look into:
- FreeRide is a free integrated development environment (IDE) for Ruby, written in Ruby itself. If you don't know what would suit you, try this one.
- If an IDE is too bulky for you, try Syn text editor (open-source)
- If even that one is too much for you, you can try Context or jEdit
- My favorite is TextMate (€40). It is only available for Mac Os X.
Using source control
This is way beyond the scope of this tutorial, but I recommend you try it if you don't work alone. It may require effort to learn, but it makes collaboration painfully simple. Actually, the .exe you've downloaded comes from the SVN repository of our project. To learn more, I recommend the book "Version Control with Subversion". The book is free to read online. You can find the whole book one one huge HTML page or as others formats such as PDF.
Scripts that don't work
A minority of scripts may not work for some reason. You can still use them by following these two steps :
1. Move the list of imports to the database. In the only script, remove the require line, keep the $: << './Scripts/' lines, then add the contents of import_all_in_original_order.rb then delete this file
2. Cut the list in 2 scripts in the database, adding the incompatible scripts where you need them
The following scripts or snippets are known to require this method:
- Auto full-screen
About the script scriptdb2rbfiles
This script is developped for another project. The current version is 1.0 beta. If people are interested in this tutorial, I will post updates to this script here.
The source of the exe is available. It was made into an .exe using rubyscript2exe.
I recommend you don't redistribute this script because it is beta quality, and in the RM world once beta-quality software is distributed it will never disappear even when updates are released. Please wait for the stable version before redistributing. In the meantime, please link here if you want to distribute the last version (new versions will appear there).
Of course, absolutely no credit is required or expected if you use this. We'd prefer to hear about your experience using this script than to get credit.