• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

GUI function for NewLine in String?

Status
Not open for further replies.
In JASS if you want a newline in a string you just have to type "\n", however I can't find out how to create a new line in a GUI string. I have tried doing the whole thing in custom script code to compensate but custom script code seems to have a character limit which prevented the thing from being completed o_O.

So does someone know how to make a newline in GUI? Yes I have tried the object editor "|n" which also yields nothing.
 
What I have now is to have an extra line that has a custom script detailing the part of the string that needs line breaks, which is set to a variable udg_TempString, and then I throw TempString into the concatenation mix.

It's just for a warning message anyway, that is displayed to users if they try to create an infinite loop from DamageEvent. I will be updating that resource in the next 7 hours to include DamageModifier as a built-in as well, I think it's for the best.
 
Level 9
Joined
Apr 26, 2011
Messages
403
lol,

you don't need to do anything in GUI,

create one trigger like below, then click on test to open string window...

then, just type whatever you want in first line, ..... now, press enter for new line
continue type something in second line.....press enter if you want more line

since you want custom script, you can always put set temp_string to custom script, then use concatenate strings to put "variable" at any line you want ?

  • Testing trigger
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Game - Display to (All players) for 90.00 seconds the text: This is Line 1 Thi...
 
Declare a variable in GUI, set it to "\n" in jass and concatenate with that variable?

  • Set s = \n
  • Game - Display to (All players) the text: (aaaaaaaaaaaa + (s + aaaaaaaaaaaaa))
Results in:
aaaaaaaaaaaa\naaaaaaaaaaaaa
It's all because in GUI additional '\' is added, so your variable look like: "\\n".

  • Custom script: set udg_s = "\n"
  • Game - Display to (All players) the text: (aaaaaaaaaaaa + (s + aaaaaaaaaaaaa))
Results in:
aaaaaaaaaaaa
aaaaaaaaaaaaa

I have just tested it. If you use custom script, "\n" is treaten as 'enter'. If in GUI - like a normal string.
Combining string set this way with concatenate strings works good.

Additionaly: Custom script limit is exactly 259 characters. Bribe, your strings much be really long ;>
 
Last edited:
Yeah I could delcare a variable named "NewLine" and set it to that, which is a good idea and all, but it's going to work out slower than what I currently have if I have to use concatenation just for something silly like that :p

I will keep the newline string in mind for next time, but for now what I have is:

  • Custom script: set udg_TempString = "texttext\ntext\ntext\ntext\ntext"
  • Game - Display to (All players)....
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
You use GUI and you care about speed?

Considering the custom script length limit, it could of course be organized in multiple lines and that is also advisable for concatenating several strings, so you do not have to replace parts by functions and rebuild the windows when willing to insert something.
 
Don't you have to double the "\" in an gui string, or maybe that is true inside a custom script ? (not sure, just something i vaguely remember)
For each '\' entered while setting string variable in GUI engine adds additional one to prevent any key-string actions, no matter what letter is after '\'.

So:
  • Set s = \\e
Looks like:set udg_s = "\\\\e"Although, if you make use of Custom script you somewhat force trigger to use the "key-strings", like normal jass do.
 
Status
Not open for further replies.
Top