[Solved] How to draw text with line breaks from string

B

bobdabilder666

Guest
I'm making a trivia game and I have a text file full of questions. I have multiple questions for one answer so I put all the questions for the same answer on one line with \n in parts of the question for the line break. My code chooses a random line to read and puts it in a string. Then draws it, but it also draws the \n and doesn't do the line break. Please help!game.png
 

TsukaYuriko

☄️
Forum Staff
Moderator
Are you using Studio 1.x? Newlines in old versions are inserted via #, not \n. \n is for Studio 2.x.
 

Evanski

Raccoon Lord
Forum Staff
Moderator
if your typing \n yourself at run time it wont line break unless you check for it and do the line break yourself
 

chamaeleon

Member
To expand on what @EvanSki said, if your file with the question literally contains \n instead of newlines, it won't be interpreted as a newline, it is simply the backslash character followed by the letter n. You could use something like this to change it.
GML:
q = string_replace_all(q, "\\n", "\n"); // GMS2, replace all occurrences of \n (written as "\\n") in the q string with a newline
 
B

bobdabilder666

Guest
Thank you all of your answers helped me solve this problem
 
Top