Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Putting the value of a variable into another variable

Hi, just beginning with Twine, and ran into a problem with variables. My basic problem is simple: I have two variables, say a name, and the name of a diner. I have the player name the character, and then the diner's default name is name's Diner. (<<set $diner = "$name's Diner">>)

When it's printed in the story, it works just fine, displaying Bob's Diner. But, the value of the variable is still "$name's Diner", which comes into play when I allow the player to select a name for the diner itself. In the textbox, it will display literally $name's Diner, which doesn't look good at all.

Now, I can use a script block to assign the value correctly, but wondered if there was a way to do it normally and more simply, in case the problem came up again.

Comments

  • Try the following, it appends the text to the current value of $name:
    <<set $diner to $name + "'s Diner">>
    
  • That did work, thanks.
Sign In or Register to comment.