设为首页收藏本站同能贴吧 切换语言 繁体中文
开启辅助访问 切换到窄版
扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 114|回复: 0

[转载发布] Editing scripts without leaving the game

[复制链接]
累计送礼:
0 个
累计收礼:
1 个
  • TA的每日心情
    开心
    2026-7-12 04:10
  • 签到天数: 209 天

    连续签到: 2 天

    [LV.7]常住居民III

    9071

    主题

    864

    回帖

    6万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    7
    卡币
    58883
    OK点
    16
    推广点
    0
    同能卷
    50
    积分
    68848

    灌水之王

    发表于 2026-8-2 20:27:38 | 显示全部楼层 |阅读模式
    [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  

    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.

                    Code:       
    1. # Name: Resque Reload
    2. # Autor: Resque
    3. # Email: rogessonb@gmail.com
    4. # Engine: RPG Maker VX
    5. # Created At: 13/08/2019
    6. # Official Source Code Repository: https://github.com/rogesson/RGSSScripts/tree/ba0b7ef4fdfa8611645bdce2b419dc1d5e5565a2/Scene_ResqueReload
    7. # Script is allowed for commercial and non-commercial games.
    8. # Do not remove this script's credits or header.
    9. class Scene_Base
    10.   RELOAD_BUTTON = :F5
    11.   SCRIPT_PATH = "Scripts"
    12.   FULL_PATH = "#{File.expand_path(Dir.pwd)}/#{SCRIPT_PATH}/*.rb"
    13.   DEBUG_MODE = true
    14.   def main
    15.     start
    16.     post_start
    17.     update until scene_changing?
    18.     pre_terminate
    19.     terminate
    20.   rescue Exception => e
    21.     reload_with_error(e)
    22.   end
    23.   def update
    24.     update_basic
    25.     reload if Input.trigger?(RELOAD_BUTTON)
    26.   end
    27.   def reload
    28.     puts "Reload Button [#{RELOAD_BUTTON}] was pressed"
    29.     puts "Reloading the Code..."
    30.     Scene_Base.load_files
    31.     call_current_scene
    32.     nil
    33.   end
    34.   def self.load_files
    35.     puts "Loading Files..."
    36.     dirs = Dir[Scene_Base::FULL_PATH]
    37.     failed = []
    38.     dirs.each do |dir|
    39.       Dir[dir].each do |file|
    40.         begin
    41.           class_name = file.split("/").last[0..-4]
    42.           autoload class_name, file
    43.           load(file)
    44.           puts "#{class_name} Loaded" if Scene_Base::DEBUG_MODE
    45.         rescue NameError => e
    46.           failed << { class_name: class_name, file: file }
    47.           next
    48.         end
    49.       end
    50.     end
    51.     self.retry_failed_files(failed)
    52.     puts "Load completed"
    53.   end
    54.   def reload_with_error(e)
    55.     error_message(e)
    56.     SceneManager.call(Scene_Title)
    57.   end
    58.   private
    59.     def self.retry_failed_files(failed_files)
    60.       failed_files.each do |f|
    61.         autoload f[:class_name], f[:file]
    62.         load(f[:file])
    63.         puts "#{f[:class_name]} Loaded" if Scene_Base::DEBUG_MODE
    64.       end
    65.     end
    66.     def error_message(e)
    67.       puts "-----------------------\nERROR: #{e} \n-> #{e.backtrace}\n-----------------------"
    68.     end
    69.     def call_current_scene
    70.       puts "#{self.class} Reloaded"
    71.       SceneManager.call(self.class)
    72.     end
    73. end
    74. Scene_Base.load_files
    复制代码




    本贴来自国际rpgmaker官方论坛作者:Resque处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/editing-scripts-without-leaving-the-game.112186/

    本帖子中包含更多资源

    您需要 登录 才可以下载或查看,没有账号?立即注册

    x
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    简体中文
    繁體中文
    English(英语)
    日本語(日语)
    Deutsch(德语)
    Русский язык(俄语)
    بالعربية(阿拉伯语)
    Türkçe(土耳其语)
    Português(葡萄牙语)
    ภาษาไทย(泰国语)
    한어(朝鲜语/韩语)
    Français(法语)
    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2026-8-17 08:30 , Processed in 0.121475 second(s), 56 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

    快速回复 返回顶部 返回列表