• 💀 Happy Halloween! 💀 It's time to vote for the best terrain! Check out the entries to Hive's HD Terrain Contest #2 - Vampire Folklore.❗️Poll closes on November 14, 2023. 🔗Click here to cast your vote!
  • 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 HD Level Design Contest #1 is OPEN! Contestants must create a maze with at least one entry point, and at least one exit point. The map should be made in HD mode, and should not be openable in SD. Only custom models from Hive's HD model and texture sections are allowed. The only exceptions are DNC models and omnilights. This is mainly a visual and design oriented contest, not technical. The UI and video walkthrough rules are there to give everyone an equal shot at victory by standardizing how viewers see the terrain. 🔗Click here to enter!

GUI function for NewLine in String?

Status
Not open for further replies.

Bribe

Code Moderator
Level 49
Joined
Sep 26, 2009
Messages
9,400
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.
 

Bribe

Code Moderator
Level 49
Joined
Sep 26, 2009
Messages
9,400
I want a game message displayed to all players, but it uses concatenation so you can't just use the first (multiline) box that pops up where you can add a new line just by typing the "Enter" key.

The string message to display is so long that it hits the GUI Custom script character limit, so I can only type half of what I currently have ;)
 

Bannar

Code Reviewer
Level 26
Joined
Mar 19, 2008
Messages
3,140
Then fail me, I wasn't carefull enough.
I'll try to find some solution later Bribe, if there is any ;)

Custom script has about 70-100 characters limit. I must test it again, cuz I wasn't using such long strings for a long long time.

Probably (if what you told is true) GUI won't give you proper method for this.
Once again GUI fails ;/
 

Bribe

Code Moderator
Level 49
Joined
Sep 26, 2009
Messages
9,400
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 8
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...
 

Bannar

Code Reviewer
Level 26
Joined
Mar 19, 2008
Messages
3,140
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:

Bribe

Code Moderator
Level 49
Joined
Sep 26, 2009
Messages
9,400
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.
 

Bannar

Code Reviewer
Level 26
Joined
Mar 19, 2008
Messages
3,140
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