GameMaker \n New Line is being Ignored in dialogs

I don't know what's going on here or if I'm the only one experiencing this. But usually, when I want to add a new line in a dialog text I would enter \n and the text would go to a new line. But recently, the \n just gets ignored.

Is anyone else having this problem?

For example, the dialog text that I want to show is:
Code:
myText[i] = "Location: Village West \n \n Village <- \n \n Forest Kingdom ->";
And I want it to be displayed like this:

"Location: Village West

Village <-
Forest Kingdom ->"

But, instead it usually shows like this in game:

Location: Village West
Village <- Forest
Kingdom ->

The \n HAS been working until recently. I have, however, found a workaround by adding a whole bunch of blank spaces, but I don't know if that would cause any distortion later on.
 

rIKmAN

Member
I don't know what's going on here or if I'm the only one experiencing this. But usually, when I want to add a new line in a dialog text I would enter \n and the text would go to a new line. But recently, the \n just gets ignored.

Is anyone else having this problem?

For example, the dialog text that I want to show is:
Code:
myText[i] = "Location: Village West \n \n Village <- \n \n Forest Kingdom ->";
And I want it to be displayed like this:

"Location: Village West

Village <-
Forest Kingdom ->"

But, instead it usually shows like this in game:

Location: Village West
Village <- Forest
Kingdom ->

The \n HAS been working until recently. I have, however, found a workaround by adding a whole bunch of blank spaces, but I don't know if that would cause any distortion later on.
What version of GMS are you using?

Just copy/pasted your string into the latest GMS2 beta and it displays as follows:
Code:
Location: Village West


  Village <-


  Forest Kingdom ->
 
What version of GMS are you using?

Just copy/pasted your string into the latest GMS2 beta and it displays as follows:
Code:
Location: Village West


  Village <-


  Forest Kingdom ->
I'm using GMS2
IDE v2.2.1.375
Runtime v.2.2.1.291

EDIT: I've also just read that in the help section it says this about adding characters like "\n" and others.

"NOTE: Strings support form feed, vertical tab etc... but this does not mean to say that rendering does, and when drawing strings these characters may be ignored."

What does that mean exactly?
 
Last edited:
I'm using GMS2
IDE v2.2.1.375
Runtime v.2.2.1.291

EDIT: I've also just read that in the help section it says this about adding characters like "\n" and others.

"NOTE: Strings support form feed, vertical tab etc... but this does not mean to say that rendering does, and when drawing strings these characters may be ignored."

What does that mean exactly?
I believe this is referring to the actual ASCII characters for things like form feed/carriage return. In other words, theoretically, these should be the same:
Code:
var str = "Hello" + chr($c) + chr($d) + "world";
var str = "Hello\nworld";
But it's not guaranteed to be rendered correctly when done the top way.
 
I believe this is referring to the actual ASCII characters for things like form feed/carriage return. In other words, theoretically, these should be the same:
Code:
var str = "Hello" + chr($c) + chr($d) + "world";
var str = "Hello\nworld";
But it's not guaranteed to be rendered correctly when done the top way.
So is it for some reason ignoring the "\n" in my line of text like
Code:
myText[i] = "Location: Village West \n \n Village <- \n \n Forest Kingdom ->";
 
Have you tried clearing the build cache (the broom button next to stop)? I'm running the exact same version of GMS2, used your code exactly, and it's rendering as expected. How are you drawing the text? I used a simple "draw_text(x,y,myText)". You can also try closing GMS2 and running it again.
 
Have you tried clearing the build cache (the broom button next to stop)? I'm running the exact same version of GMS2, used your code exactly, and it's rendering as expected. How are you drawing the text? I used a simple "draw_text(x,y,myText)". You can also try closing GMS2 and running it again.
Yeah, I've restarted and cleared the cache. I'm using a dialog system asset. So, it's not as simple as just a "draw_text(x,y,myText)". But, like I said, it WAS working at one point and actually what it does when I add the "\n" is add just another empty space " " in the line instead of creating a new line.
It also seems like it's ignoring other text character "\" functions.
 
Just to see what it would do, I tried the same text in a GUI draw_text(100, 100, "Location: Village West \n \n Village <- \n \n Forest Kingdom ->"); and it drew the text like I was wanting it to do. But, still, it doesn't draw it the right way in the other method. What could be keeping it from drawing the new lines?
 
Just to see what it would do, I tried the same text in a GUI draw_text(100, 100, "Location: Village West \n \n Village <- \n \n Forest Kingdom ->"); and it drew the text like I was wanting it to do. But, still, it doesn't draw it the right way in the other method. What could be keeping it from drawing the new lines?
All we can do is guess unless you show us this dialog system you are using. If it is something from the marketplace, or created by someone other than you, you may have to go to that person directly rather than have us just guess at stuff. We can only go on what you give us, and without having anything to show how this dialog system does the text display we might not get much further.

But at least we have confirmed that the normal draw_text() functions are working, so it is something specific to the dialog system you are using.
 
All we can do is guess unless you show us this dialog system you are using. If it is something from the marketplace, or created by someone other than you, you may have to go to that person directly rather than have us just guess at stuff. We can only go on what you give us, and without having anything to show how this dialog system does the text display we might not get much further.

But at least we have confirmed that the normal draw_text() functions are working, so it is something specific to the dialog system you are using.
I didn't post any code because I didn't know where to start with it. I first thought it was a bug. But after contacting the Asset developer, they did tell me that they intentionally made it to ignore "\n" new lines. But told me that I could make it where the dialog system checks for it.

Thanks for everyone's help though!
 
Last edited:
Top