Why does \n not work in text boxes for a new line?

Discussion in 'RPG Maker VX Ace' started by VertigoAffliction, Mar 5, 2018.

  1. VertigoAffliction

    VertigoAffliction I can still play these older games like a champ. Veteran

    Messages:
    60
    Likes Received:
    265
    Location:
    Somewhere in Spamerica
    First Language:
    ESL (English)
    Primarily Uses:
    RMVXA
    This here is something I'm quite used to using in other programs, especially in BASIC, but it doesn't work in any RM I've ever tried it in, and I'm just curious as to why.
     
    #1
  2. Jonforum

    Jonforum Veteran Veteran

    Messages:
    1,586
    Likes Received:
    1,365
    Location:
    Canada / Qu├ębec
    First Language:
    French
    Primarily Uses:
    RMMV
    because its for html balise only.
    The game run in js and not with balise div and css
     
    #2
  3. cyanic

    cyanic Veteran Veteran

    Messages:
    105
    Likes Received:
    63
    This is the VX Ace forum...

    As for the original question, it's because the string preconvert routine turned it into "\en", which is not a recognized escape sequence. If you add
    Code:
    result.gsub!(/\en/)           { "\n" }
    to Window_Base#convert_escape_characters, it'll turn it into a proper "\n", which Window_Base#process_character will process. Do note you will likely have to adjust other code to account for dynamic number of newlines in your text to make things look proper. I suggest looking at Window_Message#visible_line_number.
     
    Last edited: Mar 6, 2018
    #3
    VertigoAffliction likes this.
  4. TheoAllen

    TheoAllen Self-proclaimed jack of all trades Veteran

    Messages:
    4,453
    Likes Received:
    5,044
    Location:
    Riftverse
    First Language:
    Indonesian
    Primarily Uses:
    RMVXA
    I don't understand what "text boxes" do you mean.
    Is it a message box displayed in game dialogue? or is it the text field where you put text in editor text field?
    If it's the former, pretty sure it will display a new line if you put a script call like
    Code:
    $game_message.add("line 1\nline2\nline3")
     
    #4
    VertigoAffliction likes this.
  5. cyanic

    cyanic Veteran Veteran

    Messages:
    105
    Likes Received:
    63
    That too. However, if using the default message editor, backslashes are escaped, which leads to processing that results in not seeing newlines.
     
    #5
    VertigoAffliction likes this.
  6. TheoAllen

    TheoAllen Self-proclaimed jack of all trades Veteran

    Messages:
    4,453
    Likes Received:
    5,044
    Location:
    Riftverse
    First Language:
    Indonesian
    Primarily Uses:
    RMVXA
    @cyanic I just saw your edit.
    Imo, instead of editing the preconverted the character, why not add more escape character to process?
    Something like
    Code:
      def process_escape_character(code, text, pos)
        case code.upcase
        when 'N'
          process_new_line(text, pos) # <--- add this
        when 'C'
          change_color(text_color(obtain_escape_param(text)))
        when 'I'
          process_draw_icon(obtain_escape_param(text), pos)
        when '{'
          make_font_bigger
        when '}'
          make_font_smaller
        end
      end
    
     
    #6
    VertigoAffliction likes this.
  7. cyanic

    cyanic Veteran Veteran

    Messages:
    105
    Likes Received:
    63
    You would be introducing duplicated logic, as Window_Base#process_character already handles the newline.
     
    #7
    VertigoAffliction likes this.
  8. TheoAllen

    TheoAllen Self-proclaimed jack of all trades Veteran

    Messages:
    4,453
    Likes Received:
    5,044
    Location:
    Riftverse
    First Language:
    Indonesian
    Primarily Uses:
    RMVXA
    I know, right? modifying it is not necessary in the first place. So what text boxes in this question?
     
    #8
  9. Shaz

    Shaz Veteran Veteran

    Messages:
    37,807
    Likes Received:
    11,517
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    New lines are handled in the makers by putting in a new line. The escape characters are for other text functions - if you hover over the text entry box, you will see what they all are.

    If you want \n to force a new line in a dialogue box, you need to mod the script to look for and handle it.
     
    #9
    VertigoAffliction likes this.
  10. VertigoAffliction

    VertigoAffliction I can still play these older games like a champ. Veteran

    Messages:
    60
    Likes Received:
    265
    Location:
    Somewhere in Spamerica
    First Language:
    ESL (English)
    Primarily Uses:
    RMVXA
    Yes, I meant the dialog box that appears in game.
    But at any rate, for this to work, I see that I'd have to dig around in the established syntax.
    Well, thank you for your help on this.
     
    #10

Share This Page