Script to Ignore Text Wait Commands

Discussion in 'RGSS3 Script Requests' started by Marche100, May 26, 2019.

  1. Marche100

    Marche100 Villager Member

    Messages:
    13
    Likes Received:
    4
    First Language:
    English
    Hey, all.

    I'm making a visual novel with VX Ace (would have done it in Visual Novel Maker, but unfortunately that didn't exist until my project was well into development), and one thing I've always really liked is using VX Ace's wait commands to emulate pauses in speech. For instance, I might have a line like: "Oh,\. hey,\. Maya.\! When did you get here?" Brief pauses after commas and certain other punctuation, with a wait for player input at the end of sentences.

    However, I know there are people out there who would prefer to be rid of the text pauses and be left to read at their own pace. So, I was wondering if anyone would be willing (assuming it's possible in the first place) to create a script that ignores text wait commands (\. \| and \!) if a switch is turned on. That way, I could easily make it so the player can change the text speed whenever they want and hopefully make more people happy. Of course, if there's an easier way to do this, that works too, but as far as I know, the only way to do this in-engine would be... messy and time-consuming to say the least.

    Thanks!
     
    #1
  2. Heirukichi

    Heirukichi Veteran Veteran

    Messages:
    1,046
    Likes Received:
    381
    Location:
    Italy
    First Language:
    Italian
    Primarily Uses:
    RMVXA
    Code:
    module HRK_WMSP
      SWITCH_ID = 10 # Set this to be your switch ID
      # Do not modify after this point
      def self.skip_wait
        $game_switches[SWITCH_ID]
      end
    end
    
    class Window_Message < Window_Base
      
      alias hrk_process_escape_character_old  process_escape_character
      def process_escape_character(code, text, pos)
        if HRK_WMSP.skip_wait
          case code.upcase
          when '$'
            @gold_window.open
          when '>'
            @line_show_fast = true
          when '<'
            @line_show_fast = false
          when '^'
            @pause_skip = true
          else
            super
          end
        else
          hrk_process_escape_character_old(code, text, pos)
        end
      end
    
    end
     
    #2
    Ebanyle likes this.
  3. Sixth

    Sixth Veteran Veteran

    Messages:
    2,121
    Likes Received:
    789
    First Language:
    Hungarian
    Primarily Uses:
    RMVXA
    You are calling super instead of the alias. That will render many scripts that add new message codes in that method useless, since the new message codes will not be read when that switch is turned on.

    It would be easier to just remove those pause message codes when the switch is on before the drawing method even starts.
    Way more compatible and can be done with a single alias. Something like:
    Code:
    class Window_Base < Window
    
      alias rid_pauses9926 convert_escape_characters
      def convert_escape_characters(text)
        text = clear_pause_codes(text.clone) if $game_switches[999]
        rid_pauses9926(text)
      end
     
      def clear_pause_codes(text)
        text.gsub!("\\.","")
        text.gsub!("\\|","")
        text.gsub!("\\!","")
        return text
      end
     
    end
    
    Just replace the switch ID (999 in the snippet) with the ID of the switch you want to use.
     
    #3
    Heirukichi likes this.
  4. Heirukichi

    Heirukichi Veteran Veteran

    Messages:
    1,046
    Likes Received:
    381
    Location:
    Italy
    First Language:
    Italian
    Primarily Uses:
    RMVXA
    That one is definitely more compatible with other scripts. Although, if no script is being used to add new message codes, I would rather refrain from changing the text using gsub!, it is quite a slow method, its complexity is O(N), but it is not a very fast linear one (I wonder why though, it does not look that hard to implement efficiently to me).

    On the other hand, if scripts to add more message codes are being used, changing the text before checking those codes might be a better option.
     
    #4
  5. Marche100

    Marche100 Villager Member

    Messages:
    13
    Likes Received:
    4
    First Language:
    English
    Sorry for the late response, been a busy week.

    Thanks a bunch for your help! One question regarding where to stick these things. If I use, say, Sixth's code, I presume I would put it somewhere in Window_Base, and towards the top (before the text is drawn). And then it should automatically trigger if the switch is on, right? Just a little confused about how to use these snippets of code.
     
    #5
  6. Heirukichi

    Heirukichi Veteran Veteran

    Messages:
    1,046
    Likes Received:
    381
    Location:
    Italy
    First Language:
    Italian
    Primarily Uses:
    RMVXA
    No, both of them are supposed to be placed below Materials in your script editor. As a general rule, do not edit normal classes unless you absolutely know what you are doing.
    Mine has less compatibility issues if you place it above other scripts, Sixth's can be placed wherever you want.
     
    #6
  7. Marche100

    Marche100 Villager Member

    Messages:
    13
    Likes Received:
    4
    First Language:
    English
    Gotcha. Thanks a lot once again, both of you! This works like an absolute charm. I couldn't be happier! (And I'm sure this will make my players will be pleased as well.)
     
    #7

Share This Page