Building a text list using variables

Hello all,

                  I'm looking for some help on building a shopping cart style list with Storyline 2. I have been able to have a trigger of my choosing insert text into a text box using a text variable. So that when I click on object A, Apple appears in the text box, when I click on object B, Orange shows in the text box, etc. I've attached an example of this. However the issue is this will not build a list, instead it replaces the text each time a new object is clicked. So if I clicked Add Apple and then Add Orange I just have Orange in the text box list. I would like to have it show Apple then Orange just below it and so on building a list.

Thanks for any help or suggestions.  Mike

16 Replies
Trina Rimmer

Hi Mike. Thanks for clarifying.

I think one way you could accomplish something like this would be to use a hidden state as the initial state of your text objects.

I mocked up my own quick version of this, below, and you'll see that I've set the "Apples" text box to be hidden initially, and on each fruit "button" (the fruit pics) I've added a trigger to change the state of the appropriate text box to "normal" when the relevant fruit image is clicked. 

Initial Hidden State
This approach has the effect of populating the list with text, but not in a top to bottom order since the user can click to add fruit in any order but the apples are always at the top of the list, oranges in the middle, kiwi at the bottom—and so on.

Is this somewhat helpful or am I off base? 

Michael Buckingham

Thanks for reply Trinia. I have considered the approach you outlined above. Unfortunately the items added are actually steps in my actual e-learning, I used fruit for a simplified example. In my coarse this list is meant to track the order of steps the user has taken, step 1, step 2, step 3. The user is not held to take the steps in any specific order. There are 8 total potential steps. However the user will not be using all 8 to complete every section of the e-learning. The first section only requires 3 of the 8 to complete, but they need to be the correct 3 steps in the correct order. The list is meant to show them what steps they have taken, regardless of whether they are the correct ones. If I were to setup as above I believe there would be a large gap lets say if the user decided to pick the step 1 object and then say the step 8 object. What I would like is the item's to list in order with no gaps, no matter what order the user selects them in. Thus it would truly be a dynamic list. Someone had suggested using JavaScript function to inject a carriage return after each entry. I have not been able to find much information yet as to how to write this script code. However I think it could be a solution.

Trina Rimmer

Hey Mike. This has been an interesting challenge! I've been pretty confident that Storyline variables could get you the behavior you're looking for, but I was struggling to make it work so I brought in a few other folks. The super-talented David Anderson came up with a solution that involves the text variable (as you'd sorted) and the true/false variable to evaluate if each list item was already completed. 

Here's the example he pulled together.

And here's a glimpse at what the trigger order looks like:

Triggers

How's this looking?

Michael Buckingham

I got to say WOW. Thank you so much Trina, David, and Paul on this. I was not expecting this kind of response. Trina/David you solution is ingenious and creative. Paul you went far and above what I was expecting with a full blown demo, very cool. Now my only dilemma I have to decide which method to use. Thanks so much!  Mike 

Ray Cole

The problem is that string variables in Storyline have only one operator: assignment. So within Storyline proper, you can only ever overwrite one string with another, but not concatenate (add) anything new to the end of an existing string. Storyline really should add at least the "+" operator so we can easily do things like:

Adjust variable List to List + New_List_Item.  

Having to use Javascript for this makes it overly complicated. This is a basic string operation that should be supported directly in Storyline. It's been over two years since this issue surfaced here. How hard can it be to implement a string concatenation function in Storyline?

Cheers!

    -Ray