Arrays variables and sets, oh my

0 votes
asked Nov 6, 2017 by Liamw104 (2,780 points)
So I asked a question similar to this a while back but I am trying to make a game where the player can send fake emails.

My goal is to have a array where each sent email is added (Each email is a variable) And I am not sure how to do so.

if anyone has a idea thanks in advance

1 Answer

+1 vote
answered Nov 6, 2017 by greyelf (73,550 points)

Including code examples of what you have down or what you are trying to do can make it easier for people to understand your request.


Each (fake) email is a variable.

I am uncertain what you mean by this statement, do you mean that each "fake email" value is assigned to its own variable...

<<set $emailA to "Some value that represents a fake email">>

<<set $emailB to "Some value that represents a second fake email">>

<<set $emailC to "Some value that represents a third fake email">>

... or do you mean something else?

Anyway, the following code demonstrates how to initialise a variable to an empty Array, and how to later add three new values to that Array.

/% Initialise the sent variable to an empty Array. %/
<<set $sent to []>>

/% Add three String values to the sent Array. %/
<<set $sent.push("A")>>
<<set $sent.push("B")>>
<<set $sent.push("C")>>


commented Nov 11, 2017 by Liamw104 (2,780 points)
Each email is set via a text box and text area,

My hope is to have two variables represent a email. Ex: $Var1 (Textbox) $Var2 (Text area)

I hope that there could be 2 arrays one for the text box and one for the area.


I hope this helps.
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.