The RPG Maker Resource Kit

RMRK RPG Maker Creation => VX Ace => VXA Scripts Database => Topic started by: modern algebra on April 23, 2012, 06:55:18 PM

Title: [VXA] Escape Codes Fix
Post by: modern algebra on April 23, 2012, 06:55:18 PM
Escape Codes Fix
Version: 1.0
Author: modern algebra
Date: April 23, 2012

Version History



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


Instructions

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

Script


Code: [Select]
#==============================================================================
#    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



Thanks


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 (http://rmrk.net/index.php/topic,45481.0.html).