HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Newline Character in Strings

02-27-2009, 11:47 PM#1
ShadowWolf
Can string variables not have newline characters in them? Usually in wc3, '|n' (usually '\n' in programming languages) will cause a new line, but it isn't working in string variables. Is there a way to do this, and why doesn't |n work?
02-27-2009, 11:54 PM#2
Bobo_The_Kodo
Its \n not |n
02-28-2009, 12:06 AM#3
ShadowWolf
...but in the object editor it's '|n'... omgwtfxbbq.

edit: '\n' doesn't work either.
02-28-2009, 12:35 AM#4
akolyt0r
just make a new line...
Collapse JASS:
local string text = "This text
consists
of 3 lines"
02-28-2009, 12:44 AM#5
ShadowWolf
Can't be a local, it's a string array that I assign at map init and then reference periodically throughout the map. So there's no way to do this in GUI? That's dumb.
02-28-2009, 01:11 AM#6
akolyt0r
did some testing ... "\n" works ...
but GUI converts it to "\\n"
so you will have to use custom script to accomplish your task ...better than nothing ;)
Trigger:
Actions
Custom script: set udg_SomeString = "This Text is Followed by a Linebreak \n See ??"
02-28-2009, 01:13 AM#7
Captain Griffen
GUI you can just do it without \n at all...
02-28-2009, 01:22 AM#8
Bobo_The_Kodo
call BJDebugMsg( "Yes\nIt\nWorks" )
02-28-2009, 01:45 AM#9
Strilanc
Quote:
Originally Posted by ShadowWolf
...but in the object editor it's '|n'... omgwtfxbbq.

edit: '\n' doesn't work either.

Use ctrl+enter in the object editor for actual line breaks.
02-28-2009, 03:54 AM#10
ShadowWolf
That's really strange.
Trigger:
Custom script: set udg_string_LevelDescription[1] = "-|cffffcc00Level 1|r-\n|c00ff0000Special:|r None\n|c00804040Armor:|r Unarmored"
Set string_LevelDescription[1] = -|cffffcc00Level 1|r-\n|c00ff0000Special:|r None\n|c00804040Armor:|r Unarmored
Using custom script, the \n works, but using the GUI's set variable function, it doesn't (even though when converted they're the same exact thing)
+1 for JASS
02-28-2009, 03:58 AM#11
Vexorian
The GUI part probably automatically converts "\n" to "\\n"