Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

New line in string value without using \n or it breaks script?

Asked by 6 years ago
print(("%q"):format('first line \n second line') 
--will print like
first line \
second line

So I'm making this one program where I need the ability to make a new line of text when I want to, however using format:\n thing causes the last part of the first line to get a \ at the end.

That will break my script, thus I need some way to make the new line like above, but it doesn't cause that annoying \ at the end of the previous line. FYI this will eventually be used in a Textbox, the script above still writes it to the text box correctly, the \ will just break the script when I go back to read it.

0
Works fine for me when I do "print('a sentence\nanother sentence')" hiimgoodpack 2009 — 6y
0
Have you tried using %s instead of %q? XAXA 1569 — 6y
0
Have you tried not using :format in the first place? hiimgoodpack 2009 — 6y

Answer this question