How do I concatenate text variables in Storyline 2?

Hi all,

I need to be able to concatenate a text variable with specific text. For example, starting with the text variable myname a user enters their name and it is assigned to this variable using a Text Entry object.  Later, when they have completed an activity, I want to concatenate "done" to the current value of the text variable. So, the result will be myname+ done (the space in front of done is being added with done so there is a space between the 2 words).

I've read that this can only be done by using JavaScript, of which I know nothing. So, I'm hoping one of our Heroes or Staff can guide me in using the JavaScript trigger to do this concatenation.


5 Replies
Russell Lash

Greetings Matthew - thank you for the lead, but it was not helpful. The fruit stand example, with the JavaScript was developed in Storyline 3 (or 360) and I'm using v2.  But from looking at the run time version of the stand, it looks like it is number variable manipulation (adding), not text variable concatenation.   The other example, in v2, is nothing more than a variable content change, not concatenation and there is no JavaScript.

Do you have any other text variable concatenation JavaScript examples in V2?


//Call the StoryLine player
var player = GetPlayer();

//Get the name from StoryLine and add a text value at the end of it
var combine = player.GetVar("StoryLineVariable") + " done";

//Send the new value back to a StoryLine variable
player.SetVar("CombinedStoryLineVariabe", combine);

Phil Mayor

Sorry didn't realise I did not post the storyline file. It was text concatenation as it was only way to b=get the numbers to have two decimal places. , not a great file as I kept bolting stuff on.

The SL2 file was here

Not the most elegant solution