Hi,
I'm using default Sugarcube install in Twine 2. I have a passage that is intended to be only accessed as part of other passages (it gives custom descriptions which I'll want to add as a snippet in a number of different places) so is accessed, currently, using the <<display "Description Passage">> command.
As part of that, I'd like it to grab a variable from another passage which gives yet another part of a description. A schematic would look like (ignore the missing <<nobr>>s: lazy):
Story Passage
You see something, it's a <<display "Description">> something.
Description
<<goto "Size Description">>
<<set $description to "relatively">>
<<set $description += $size>>
<<print $description>>
<<goto previous()>>
Size Description
<<if $thingSize = 0>>
<<set $size to "small">>
<<else>>
<<set $size to "big">>
<</if>>
<<goto previous()>>
However, when I run that I get:
Error: <<goto>>: passage "previous()" does not exist
My code's working - if I call Size Description from Story Passage it works fine. I'm assuming that the issue is that the <<display>> command isn't working alongside previous() - for instance passages accessed through <<display>> don't correctly set up their name or the purposes of previous().
1) Am I correct in identifying the error and
2) Is there a work around for this? I'd sooner not change the structure of the code too much as I need both Size Description and Description functioning as they are.
Hopefully the question makes sense! Any help appreciated.
Comments
First to clear up a couple of misconceptions you may have.
1. The <<display>> macro basically embeds the content of the Other passage into the Current one, it does not navigate the Reader to that Other passage so there is no need for a <<goto>> macro to return them to the Current one.
2. A single equals sign = operator is use to assign a value to a variable, you need to use the double (or triple) equals sign == (===) operator when comparing two values within an <<if>> like macro. I suggest you start using the to and is operators instead.
You can use the <<display>> macro to process a passage that contains only logic, like your Size Description passage.
The following are modified versions of your Description and Size Description passages.
a. Description b. Size Description
note: You can use TWEE notation if you need to include more than a single passage in an example.