Original Source
- Original title: Editing scripts without leaving the game
- Original author: Resque
- Original date: August 14, 2019
- Source thread: https://forums.rpgmakerweb.com/threads/editing-scripts-without-leaving-the-game.112186/
- Source forum path: Game Development Engines > Ruby Game System (RGSS) Scripts > RGSS3 Scripts (RMVX Ace)
Summary
[RPG Maker VX] Editing scripts without leaving the game Hello guys! All right with you? Today I'm bringing a script called Scene_ResqueReload that I created for use in my projects that are in RPG Maker VX Ace . The Reason
Archived First Post
Hello guys! All right with you?
Today I'm bringing a script called Scene_ResqueReload that I created for use in my projects that are in RPG Maker VX Ace .
The Reason
Unlike many scripts that add new functionality to the game, this script is used as a tool that facilitates the real-time testing of code editing in RPG Maker VX Ace.
Often you need to have a quick response if the changed code is working. It gets more and more stressful when an error occurs in the script and you need several clicks on the tool to open the editor, edit the code, save changes and restart the game.
I have always found limiting the use of the integrated text editor that RPG Maker makes available for code change as there are a wide variety of text editors that provide various tools to help us at that time.
I really enjoy using Sublime Text to program, it has several shortcuts, search engines and numerous text editing tools.
Other text editors can easily be found on the web, whether they are paid, free and even open source. Using this script, you will be able to use the text editor of your choice, be it Sublime, VIM, Atom, Notepad ++, Visual Studio Code, etc ...
Theory
Basically, when the game is started, the script reads a directory within your RPG Maker project and loads the external
files Ruby (.rb) into the game.
By default, the script is set to read the "Scripts" folder of your project's root directory, this folder does not exists by default, so you need to manually create and place your .rb files inside it.
Since we are reading an external file, it is possible to reload the code without closing the game by simply pressing the "F5" key on your keyboard when you are playing the game.
This allows you to change the code in your editor and see the change in your game without closing the game!
The Practice
To use the script, just create the "Scripts" folder within the root directory of your Maker project and create your custom script (.rb) files.
After performing the above step, you need to open open the Standard RPG Maker Text Editor and add the script Resque_Reload to the last line.
Ready! The next time that you open the game, all .rb files in the "Scripts" directory will be read automatically.
The Benefits
Besides using any editor, the script allows you to use version control tools like (Git, CVS, Subversion, Mercurial, etc ...), in case your computer explodes or your game gets corrupted, you will have all your code in a safe place.
Also, whenever you receive a code error, your game no will no longer be closed after this message appears:
Now the error message will appear on the Debug screen, with much more information about the error, and your game will automatically go to the home screen (you can see it in the video below)
The Code
The script allows some settings to be changed on its first lines:
- Reading Folder Name:
The default name is "Scripts" but can be changed to any other name (as long as the folder has the same name.)
- Reload key:
By default the F5 button reloads the game in real time, but this key can be changed to one of your own.
Below is the source code of the script and its latest version on Github, plus a video demonstrating how the script works, where I make several changes to a script, changing the displayed name, positioning and causing errors:
If in doubt, I'll always be here, thanks!!
https://github.com/rogesson/RGSSScr...11645bdce2b419dc1d5e5565a2/Scene_ResqueReload
Terms
Script Name: Resque Reload
Autor: Resque
Email: rogessonb@gmail.com
Engine: RPG Maker VX
Created At: 13/08/2019
Official Source Code Repository: https://github.com/rogesson/RGSSScr...11645bdce2b419dc1d5e5565a2/Scene_ResqueReload
This script is allowed for commercial and non-commercial games.
Feel free to use it, don't need to credit me in your game.
If you want to share, you must link this post to ensure there are no out of date versions floating around the internet.
# Name: Resque Reload
# Autor: Resque
# Email: rogessonb@gmail.com
# Engine: RPG Maker VX
# Created At: 13/08/2019
# Official Source Code Repository: https://github.com/rogesson/RGSSScripts/tree/ba0b7ef4fdfa8611645bdce2b419dc1d5e5565a2/Scene_ResqueReload
# Script is allowed for commercial and non-commercial games.
# Do not remove this script's credits or header.
class Scene_Base
RELOAD_BUTTON = :F5
SCRIPT_PATH = "Scripts"
FULL_PATH = "#{File.expand_path(Dir.pwd)}/#{SCRIPT_PATH}/*.rb"
DEBUG_MODE = true
def main
start
post_start
update until scene_changing?
pre_terminate
terminate
rescue Exception => e
reload_with_error(e)
end
def update
update_basic
reload if Input.trigger?(RELOAD_BUTTON)
end
def reload
puts "Reload Button [#{RELOAD_BUTTON}] was pressed"
puts "Reloading the Code..."
Scene_Base.load_files
call_current_scene
nil
end
def self.load_files
puts "Loading Files..."
dirs = Dir[Scene_Base::FULL_PATH]
failed = []
dirs.each do |dir|
Dir[dir].each do |file|
begin
class_name = file.split("/").last[0..-4]
autoload class_name, file
load(file)
puts "#{class_name} Loaded" if Scene_Base::DEBUG_MODE
rescue NameError => e
failed << { class_name: class_name, file: file }
next
end
end
end
self.retry_failed_files(failed)
puts "Load completed"
end
def reload_with_error(e)
error_message(e)
SceneManager.call(Scene_Title)
end
private
def self.retry_failed_files(failed_files)
failed_files.each do |f|
autoload f[:class_name], f[:file]
load(f[:file])
puts "#{f[:class_name]} Loaded" if Scene_Base::DEBUG_MODE
end
end
def error_message(e)
puts "-----------------------\nERROR: #{e} \n-> #{e.backtrace}\n-----------------------"
end
def call_current_scene
puts "#{self.class} Reloaded"
SceneManager.call(self.class)
end
end
Scene_Base.load_files
Downloads / Referenced Files
Log in, then follow the RPG Maker Developers Group to see these download links.
Log in to downloadLicense / Terms Note
This script is allowed for commercial and non-commercial games. Feel free to use it, don't need to credit me in your game. If you want to share, you must link this post to ensure there are no out of date versions floating around the internet. Code:
Creator Claims / Removal
If you are the original creator and want this listing reassigned, edited, or removed, join BMMPlay and contact the moderators with proof that matches the original RPG Maker Web profile, linked GitHub, itch.io page, or another public creator identity.
Replies (0)
No replies yet.
Topic Summary
Loading summary...