0 votes
by (2.9k points)
Hi, I have been using twine 2 (Sugarcube) for a while but I am trying to find out how to make my game create variables without me needing to go and program them EX., User created information like documents. If anyone knows how I can accomplish this please comment how.

1 Answer

+1 vote
by (63.1k points)
It's hard to tell exactly what you mean. If you tell us what you plan to use this feature for, we may be able to give you some advice.
by (2.9k points)
My goal is to have my game create multiple variables EX. var1,var2,var3 that can store data which can be named anything the user wishes to name it.

Another way of explaining it is that the player answers a question In a Text field then they can answer again in the same text field without having to overwrite the previous answer.
by (63.1k points)

You mean like an array? 

<<set $answers to []>>
<<set $ans to ''>>

::some passage
<<if $ans>>\
    <<run $answers.push($ans)>>\
<<set $ans to ''>>\
<<textbox '$ans' '' 'some passage' autofocus>>

<<button 'Submit' 'some passage'>><</button>>

<<print $answers.join('\n')>>

This code was written from memory and wasn't tested, so it may contain some silly errors.