RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
[VXA] Escape Codes Fix

0 Members and 1 Guest are viewing this topic.

*
Rep:
Level 97
2014 Best RPG Maker User - Engine2014 Most Unsung Member2013 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best RPG Maker User (Scripting)2011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best Use of Avatar and Signature Space2010 Favourite Staff Member2010 Most Mature Member
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


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


  • 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.
« Last Edit: January 31, 2013, 09:48:34 PM by modern algebra »