• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

[Solved] Drawing a string with line break (or any \) created from "outside"

D

Dawn

Guest
It seems \ does not work for a string variable set by included files.

For example,

draw_text(x,y,"A\nB");
This works.

str="A\nB";
draw_text(x,y,str;
This works too.

//value of str is copied from a grid created from a CSV file containing texts
draw_text(x,y,str);
This shows the text literally with no line break but \n.

I think it happened in 1.4 too but I'm not sure it's a bug or I missed something.
 
D

Dawn

Guest
Nevermind. Solved it by using
string_replace_all(txt,"\\n","\n");
 

YellowAfterlife

ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ
Forum Staff
Moderator
It seems \ does not work for a string variable set by included files.
\ escape sequences are only for strings inside the code.
If you want escape sequences inside externally loaded strings, you'd handle them yourself (just as you have already figured out)
 
Top