RMRK is retiring.
Server is paid up for the rest of 2026, but the forum may go after that. See here for more information. Please archive or save anything you would like to keep before 2027.
Main Menu
  • Welcome to The RPG Maker Resource Kit.

[VXA] Escape Codes Fix

Started by modern algebra, April 23, 2012, 06:55:18 PM

0 Members and 1 Guest are viewing this topic.

modern algebra

Escape Codes Fix
Version: 1.0
Author: modern algebra
Date: April 23, 2012

Version History




  • <Version 1.0> 2012.04.23 - Original Release

Description



By default, a small oversight when using message codes can crash the game. By forgetting to include any code between \ and [, the game would crash. For instance, the following message would crash the game:

      Hello \c[12]Ralph\[0], and welcome to RMVX Ace.

This happens because you forgot to put a c between the second \ and [. This script fixes that error and puts a message in the console saying that it happened.

Features


  • Doesn't crash the game when you accidentally fail to place a code between \ and [ when using message codes.
  • Prints a simple message in the console advising you of the error instead.

Instructions

Paste this script into its own slot in the Script Editor, above Main but below Materials.

Script




#==============================================================================
#    Escape Codes Fix
#    Version: 1.0
#    Author: modern algebra (rmrk.net)
#    Date: April 23, 2012
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Description:
#
#    By default, the game would crash if you neglected to put any code between
#   a \ and [ when using message codes. This fix makes the error less
#   catastrophic by simply printing a message in the console.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Instructions:
#
#    Simply paste this script into its own slot in the Script Editor, above
#   Main but below Materials.
#==============================================================================

$imported ||= {}
unless $imported[:MA_EscapeCodesFix]
  #============================================================================
  # ** Window_Base
  #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  #  Summary of Changes:
  #    aliased method - obtain_escape_code
  #============================================================================

  class Window_Base
    alias maatspf_obtainesccode_2jk3 obtain_escape_code
    def obtain_escape_code(*args, &block)
      code = maatspf_obtainesccode_2jk3(*args, &block)
      if code.nil?
        p "ERROR in #{self}:\nThere is no escaped code between \ and [ in your text."
        ""
      else
        code
      end
    end
  end
  $imported[:MA_EscapeCodesFix] = true
end


Credit




  • modern algebra

Thanks


  • D&P3, for alerting me to the error

Support



Please post in this thread at RMRK if you have any questions or encounter any errors. Please do not PM me or start a new topic for support, no matter how old is this thread. The reason for that is that any question or problem you have is likely shared by others, and I would like whatever answer I can give to benefit as many people as possible by being both public and conveniently accessed.

Known Compatibility Issues

I am currently unaware of any compatibility issues and do not expect any to arise.

Terms of Use

I adopt the Terms of Use for RMVXA Scripts Database.