Forum Discussion

IvanDzurek-e393's avatar
IvanDzurek-e393
Community Member
6 months ago

text variable within another text variable

Hello. In my course I'm doing a choose-your-own-adventure style conversation. A user gets choices A and B and depending on what they click, a variable will be filled with an answer and displayed within the conversation.

So my triggers look like this:

Set "callChoice1" to value "some text is in here" when the user clicks Choice1A.

That's simple enough and works nicely. However, previously in the course the user entered their name and it's recorded in the variable Name. When I want one of the answers to contain that name, my trigger is:

Set "callChoice1" to value "some text and %Name% here" when the user clicks Choice1A.

But this doesn't work. When I display the answer as %callChoice1% in my speech bubble, the Name variable doesn't load in its value, my text is just literally displayed as "some text and %Name% here" instead of "some text and John here"

Is it possible to make a variable within a variable work in this way?

Thanks

  • Unfortunately, the only option to adjust a text variable is "Set." And you can only set it to a given value or the value of another variable. You can't combine values, and you can't insert text before or after the value (e.g., to create a list or the type of sentence you want). 

    Thus, to get a combination, you need to reference separate variables, e.g., the text box contains "%callChoice% and %Name% here."

    FYI: I've submitted a feature request for triggers that would allow adding text (before or after current value) instead of just setting/replacing text. You can submit a feature request here: https://access.articulate.com/support/contact/feature-request

    • Submitting a request doesn't guarantee that a feature will be implemented. But how many people request a feature could have some impact on the decision-making process.
  • I asked chatGPT to help and it made a javascript that strings it all together. Works fine like this.

    var name = GetPlayer().GetVar("Name");
    var callChoice1 = "some text and " + name + " here";
    var player = GetPlayer();
    player.SetVar("callChoice1", callChoice1);

    • JudyNollet's avatar
      JudyNollet
      Super Hero

      Yes, JavaScript can be used for that sort of thing. I'm sorry I neglected to mention that in my previous response, which was based only on what can be done with Storyline triggers.