Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

How to set up your RMXP project to use .rb files in less than 15 minutes

Youpi

Member

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:

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.
 
I like the new way to edit the scripts. However, it would be nice to convert the rest of the database over to rb files. But that asks too much.

good work
 
Well instead of adding a new file you have to add it to the list for require why not use Dir.entries and automatically require each of those files so that the user would just have to add it to the folder (Seph did write some code for me for this)

There are a few drawbacks to this system though

You can edit the files and they can not be encrypted meaning someone like me with good scripting knowledge can easily go into the files and edit them to our advantage

Also scripts can easily be taken by the people who download the person's project. so :-/
 

Youpi

Member

Well, the encryption thing is not reality in my mentality, I think that if someone can benefit from what I do, good for him. But if you are concerned about that, there are two things you can do:
- Use a Ruby obfuscator. I do not know if a good one exist, Google suggest that yes
- Analyze the export script to make a re-import script (the .exe is 1,5MB, but the source is less than 100 lines of well commented ruby code).

I don't like the idea of importing everything automatically since RMXP expects things to be in a certain order.


Also, being able to read the rest of the .rxdata is part of the project thant lead us to make scriptdb2rbfiles (but exporting them isn't really). They are just marshaled Ruby objects, so converting them to an arbitrary format would be pretty trivial.
 
This is a little off-topic, but since you suggested FreeRIDE, do you know a way to open Game.exe direct from FreeRIDE. You know, everytime I wish to test my scripts I have to minimize freeride and open the exe from explorer.
EDIT: Forget it, I managed it creating a 'test.rb' as the default script with the following code:
Code:
exec '../Game.exe'
 

Youpi

Member

Have some other people tried out the tutorial? I don't want to nag, but it'd be a real help if people who used this could tell me about their experience with it, good or bad, or even why you didn't consider performing this conversion. (please let me know by PM if you don't want to clutter the thread)
Thanks!
 
Probably not, as .so files needs to fit in memory (Shared Objects), and that's what crashes rmxp. His method, while interesting, only relocates the source, but doesn't change the way game.exe works.
 

Jereth

Member

Try it with SDK 2.2 and both the Method Classes from Seph's testbed and MACL 2.0 and see if it works for you, then I'll know it's something on my end.
 
I'm running Vista Home Basic so the paths are a bit different, anyone know how I could use this in Vista?
EDIT: The path of the game folder is C:\Users\Lohdro\Documents\RPGXP\Demo1
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top