Self creating user input variables?

0 votes
asked Aug 3, 2017 by Liamw104 (2,780 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
answered Aug 4, 2017 by Chapel (40,930 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.
commented Aug 8, 2017 by Liamw104 (2,780 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.
commented Aug 8, 2017 by Chapel (40,930 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.