0 votes
asked 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
answered by (52.5k 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 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.
commented by (52.5k points)

You mean like an array? 

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

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

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

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

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

Welcome to Twine Q&A, where you can ask questions and receive answers from other members of the community.

You can also find hints and information on Twine on the official wiki and the old forums archive.

See a spam question? Flag it instead of downvoting. A question flagged enough times will automatically be hidden while moderators review it.
...