The RPG Maker Resource Kit

RMRK RPG Maker Creation => VX Ace => VXA Scripts Database => Topic started by: BilouMaster on February 11, 2018, 04:34:17 PM

Title: [VXA] scripts-externalizer, loader, compiler
Post by: BilouMaster on February 11, 2018, 04:34:17 PM
Join us on Discord ! (https://discord.gg/yRUZcdQ)

(https://rmrk.net/proxy.php?request=http%3A%2F%2Frmex.github.io%2Fimages%2Frmex-shortcut.png&hash=2f9b9510f739426acf4dbd5d7b4d57e6ad2ba699) (http://rmex.github.io) scripts-externalizer
Quote
Externalize all scripts from Scripts.rvdata2 (script for RMVXAce)

scripts-externalizer, scripts-loader and scripts-compiler allow you to use your favorite IDE instead of the RPG Maker script editor!



About using the default script editor



What is externalization?

The externalization is the way of working with external scripts, they are ruby files (foo.rb). The project will load your scripts files and rock with them, even if your scripts aren't into the script editor!

To put it simply, you can externalize a script by yourself using the simple function:
Code: [Select]
Kernel.send(:load, 'yourpath/yourscript.rb')
or :
Code: [Select]
Kernel.send(:require, 'yourpath/yourscript.rb')

`Kernel.load` and `Kernel.require` exist in Ruby 1.9.2 but the RGSS3 privatized them... Lucky that we still can use the *SUPER TRICK* of `.send`!

The difference between `:load` and `:require` is that `:require` will not load two times the same script. `:require` is recommanded when you want to manage dependency between multiple scripts.

I propose to use those functions smartly, by using my scripts!


What about the scripts-externalizer, loader and compiler?

There is three way of utilising those scripts:



Externalize just the scripts you want (scripts-loader (https://raw.githubusercontent.com/RMEx/scripts-externalizer/master/scripts-loader.rb))

It's quite simple:


For example:
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fbiloucorp.com%2FBCW%2FJoke%2Fsample2.png&hash=8e3fc6f368929829359264d14dc4e8a1e9d3e6fd)

(https://rmrk.net/proxy.php?request=http%3A%2F%2Fbiloucorp.com%2FBCW%2FJoke%2Fsample1.png&hash=b8a70b6510eb9c58b0fe67b215579917f07d7e77)

Into the "_list.rb", there is just:
Code: [Select]
Fullscreen++
orms
Those two scripts will be loaded at the same time of scripts-loader

If you want to deactivate Fullscreen++, just put a "#" in front of the name:
Code: [Select]
#Fullscreen++
orms
That's PERFECT for debugging!

The "_list.rb" is very important because it defines in which order your scripts will be loaded.

For example:
Code: [Select]
orms
Fullscreen++
orms will be loaded before Fullscreen++ (what it is precisely NOT what to do since orms manages the compatibility between the two)

---
Create sub-folders in "Scripts"

You can easily create any folder you want, even folders into folders

You must specify the folder by adding his name into the "_list.rb", with a "/" after (and not a "\\", be careful)
Code: [Select]
RME/
Fullscreen++
orms
Into your new folder, you have to create a new "_list.rb" to define the order of the scripts and the next sub-folders.
For example, in the folder "RME", you have this "_list.rb":
Code: [Select]
Event_printer
SDK.Sample
Samples
SDK
Database
Internal
EvEx
Commands
Incubator
DocGenerator
Doc
SDK.Gui
Tools
Process.Doc

Externalize all scripts including the default scripts (scripts-externalizer (https://raw.githubusercontent.com/RMEx/scripts-externalizer/master/scripts-externalizer.rb))

Here come the best!

Quote from: Frogge on the RPGMaker.net discord server
THE SCRIPT TO END ALL SCRIPTS

You can externalize ALL scripts including the default scripts by using the scripts-externalizer instead of the scripts-loader!

It will create the "Scripts" folder, and make automatically the sub-folders respecting the categories defined by empty scripts like "▼ Scenes"

Add "scripts-externalizer" into your project:

(https://rmrk.net/proxy.php?request=http%3A%2F%2Fbiloucorp.com%2FBCW%2FJoke%2Fsample3.png&hash=0fd4e55db6152d0004b2f932c1aa93e0100a4c5c)

Then launch the game:

(https://rmrk.net/proxy.php?request=http%3A%2F%2Fbiloucorp.com%2FBCW%2FJoke%2Fsample4.png&hash=ba9f4f35a92959d3d7149f64746e9e9c368d9854)

`battle_end_me.play`

(https://rmrk.net/proxy.php?request=http%3A%2F%2Fbiloucorp.com%2FBCW%2FJoke%2Fsample5.png&hash=d941d6664b427aa0e66881a228eb99f5fcaadd6d)

Close and open the project...

NOW THE SCRIPT EDITOR IS KILLED!!!

(https://rmrk.net/proxy.php?request=http%3A%2F%2Fbiloucorp.com%2FBCW%2FJoke%2Fsample6.png&hash=c50b5bce9a16db1ae56ba3a9a3df7f0cf07ee7ef)

Don't worry, you will retrieve all the scripts in your favorite IDE :) :

(https://rmrk.net/proxy.php?request=http%3A%2F%2Fbiloucorp.com%2FBCW%2FJoke%2Fsample7.png&hash=64448e00b1c2bd3176db7368e09104d3d56894a2)

Security



Compiling the external scripts into the Scripts.rvdata2 (scripts-compiler (https://raw.githubusercontent.com/RMEx/scripts-externalizer/master/scripts-compiler.rb))

You can use the scripts-compiler to compile the content of your "Scripts" folder into "Scripts.rvdata2"

Just add the "scripts-compiler" in your scripts (replace the "scripts-loader" you used):

(https://rmrk.net/proxy.php?request=http%3A%2F%2Fbiloucorp.com%2FBCW%2FJoke%2Fsample8.png&hash=e3aedbc4025107479033451a4ec946a88606a3ca)

Launch the game, then close/open the project, and VOILA:

(https://rmrk.net/proxy.php?request=http%3A%2F%2Fbiloucorp.com%2FBCW%2FJoke%2Fsample10.png&hash=f466de0544f21f70d39155d72bd2b27c1c110e9b)

You can see the sub-folder is represented by the character "■" in front of the name. The "scripts-externalizer" understand those characters and creates the sub-folders corresponding!

The scripts-compiler works even if you externalized ALL scripts. :)

Security


Compile your scripts before releasing your game!

You will notice the game will start after few seconds (2~3) if your scripts are externalized... It's not a problem since you save A LOT of time by editing external scripts instead of internal scripts. But when you don't work on your scripts or when you want to release your game, I recommand you to compile your scripts to avoid those few little seconds lost.


Sample_project_1 (https://github.com/RMEx/scripts-externalizer/tree/master/Sample_project_1) and Sample_project_2 (https://github.com/RMEx/scripts-externalizer/tree/master/Sample_project_2)

Those projects are the projects I used as example, you can see how the scripts are managed in Sample_project_1 with the method of scripts-externalize all scripts.

You can see how the scripts are managed in Sample_project_2 with the method of scripts-loader that loads just the scripts you want to externalize.

That's all, folks! <3