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

VertigoAffliction

I can still play these older games like a champ.
Veteran
Joined
Feb 13, 2018
Messages
60
Reaction score
265
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.
 

Jonforum

Veteran
Veteran
Joined
Mar 28, 2016
Messages
1,623
Reaction score
1,439
First Language
French
Primarily Uses
RMMV
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.
because its for html balise only.
The game run in js and not with balise div and css
 

cyanic

Veteran
Veteran
Joined
Nov 16, 2015
Messages
106
Reaction score
71
Primarily Uses
because its for html balise only.
The game run in js and not with balise div and css
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:

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,592
Reaction score
6,522
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")
 

cyanic

Veteran
Veteran
Joined
Nov 16, 2015
Messages
106
Reaction score
71
Primarily Uses
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")
That too. However, if using the default message editor, backslashes are escaped, which leads to processing that results in not seeing newlines.
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,592
Reaction score
6,522
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
 

cyanic

Veteran
Veteran
Joined
Nov 16, 2015
Messages
106
Reaction score
71
Primarily Uses
You would be introducing duplicated logic, as Window_Base#process_character already handles the newline.
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,592
Reaction score
6,522
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?
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
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.
 

VertigoAffliction

I can still play these older games like a champ.
Veteran
Joined
Feb 13, 2018
Messages
60
Reaction score
265
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.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,862
Messages
1,017,049
Members
137,570
Latest member
fgfhdfg
Top