• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Solved] Enter or Line Break in Concatenated Strings

Status
Not open for further replies.
Level 5
Joined
Dec 3, 2012
Messages
117
So in my map, quest NPCs will sometimes have to say something that I've stored in a variable (i.e. player name, unit name, item name etc etc.) Now I use Concatenate strings for this to convert the variable to a string and show it, but the problem is.

I use quest NPC messages like this:
Quest NPC Name:
Quest NPC Text, blablabla

But when Concatenate strings is used it will be showed like this:
Quest NPC Name: Quest NPC Text, blablabla

I need a way to either force an enter in concatenate strings, or avoid using it, by maybe something like;

Quest NPC Name:
Quest NPC Text, String(GetVariable), blablabla

or something like that D:
 
Last edited by a moderator:
Level 5
Joined
Dec 3, 2012
Messages
117
The hell? I could've sworn I tested this, yet now I find out it's not working.

Here's my action:
  • Game - Display to TEMPPlayerGroup the text: (|cffffcc00Expert Mage:|r|cff1e90ff\n...Alright, everything seems to be in order. Your name is... |r|cffffcc00 + ((Name of (Triggering player)) + |r|cff1e90ff? A good name.|r))
The \n is right after the NPC's name

But what it shows in game is:
Expert Mage:\n...Alright, everything seems to .... etc
 
Oops, my mistake. All strings entered in GUI are stored in a file within the map called "war3map.wts", and it doesn't process the escape sequences (what you see is what you get, except for color codes). So if you type \n in GUI, it will show up as \n in that file (which is "\\n" in JASS).

Here is a little work around that might help. Just declare this on map initialization:
  • LineBreak
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Custom script: set udg_Linebreak = "\n"
You should have a string variable named Linebreak.

Then, whenever you want to add an "enter"/linebreak in a concatenated string, just add the linebreak:
ex:
  • Game - Display to (All players) the text: (Hello + (Linebreak + World))
You would have to use an extra concatenation to join the linebreak with the text. In may case, it is "Hello" + ("\n" + "World"), where "\n" is the value of the variable Linebreak (as set in the initialization trigger). When you test it in game, it will show up as:

Hello
World

It is a bit makeshift, but at least it works.

EDIT: I reverted the [Solved] prefix. Let me know if it works for you, and then I will mark it back if it does.
 
Status
Not open for further replies.
Top