Howdy, Stranger!

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

Substituting/Setting A Variable's Name Using Another Variable's String (Sugarcube 2)

edited April 2016 in Help! with 1.x
Can this be done using Twine's script, or am I going to have to use javascript? If javascript is the only way to do it, has anyone already done this, and wouldn't mind sharing?


  • You can use the <<print>> macro to convert a String containing a marco into the actual macro call.
    <<set $number to 0>>
    <<set $var to "$number">>
    <<print "<<set " + $var + " to 10>>">>
    number: $number
  • Sweet. Thanks! Exactly what I was looking for. Though I won't pretend I get why <<print>> does that...
  • The <<print>> macro processes the String and adds the result to the current output, which in this case is a <<set>> macro which in turn gets processed and changes the $number variable.
Sign In or Register to comment.