+1 vote
by (170 points)
Hi guys, I'm making my first game and it's been a blast so far, but I can't get a feature withing the game to work the way I want it to. Latest Twine 2 and Sugarcube 2. I have the following:


Passage: Notebook

Text: Make Notes here! They help you remember.

[[Add a Note|Addnotes]]

Note 1:
<<print $note1>>


Passage: Addnotes

<<textarea "$note1" "$note1">>

((($note1 is set in StoryInit to "Blank")))

[[Go back|Notebook]]


I want to make the <<textarea>> have the previously changed $note1 so that the player can add info to his note, rewrite it and so on. If in Addnotes I set the $note1 to "Go to the big red building with the yellow sign or something" and click the go back link in my Notebook passage it's correctly displayed as Note 1: "Go to the big red building with the yellow sign or something". But when I go to Addnotes a second time the <<textarea>> has the text $note1 in it, but not the actual value I previously entered, just the name of this variable. It also leads to an error Maximum call stack size exceeded.

So my question is - Is it possible to have the value of $note1 in the <<textarea>> as a default value? Is there a smarter way to make a notebook with editable entries?

1 Answer

+1 vote
by (63.1k points)
selected by
Best answer

Lose the quotes around the second $note1. I.e. 

<<textarea "$note1" $note1>>

Also, anytime you're numbering your variables, you're usually looking for an array, so look into arrays. They'll probably make your system work a little better. 

by (170 points)
Ah, so simple, thank you! I saw arrays being recommended in similar cases, but I am just beginning to learn about twine and coding in general so I wanted to do it in the most basic way possible for a beginner project. I'm reading the Sugarcube documentation as much as I can but for some reason I thought that the default value in the textarea should always be in quotes.