Return initial state error

I have added <<return>> to my story. It is placed in the PassageFooter where I have create a custom interface, may change this. But after I enter the story the <<return>> displays as an error. Is there a way to init this correctly?

Error: <<return>>: cannot find passage <<return "Back">>

So as a work around i’m manually initing the <<return>> by putting <<set $retBack to false>> into my StoryInit passage. Then in PassageFooter I replaced <<return "Back">> with <<if $retBack is true>> <<return "Back">> <<else>> <<set $retBack to true>> <</if>> . This seems to work ok.

Thanks

The <<return>> macro will fail if used in the first Passage shown by the project, because there is no previous Passage in the Progress History to return to.

The simplest way to resolve your issue is to use the State.length property to determine if the History contains more than just the Passage being visited…
eg. Change the content of your PassageFooter to…

<<if State.length > 1>><<return>><</if>>

warning: The <<return>> macro is basically the equivalent of the following link macro call…

<<link "Return" `previous()`>><</link>>

…and unfortunately if links that transition to the previous Passage are selected multiple times in a row the Reader can end up in a progression loop.

eg. If the project consists of three sequential Passages named A, B, an C. So the expected path would be…

A -> B -> C

And if the Reader used a “return” type Link while visiting B then they would be returned to A, all good so far…

A -> B -> A

And if the Reader used a “return” type Link again, they would be returned to B…

A -> B -> A -> B

…and now the Reader is in a progression loop if there is no other Link to select besides the “return” type Link…

A -> B -> A -> B -> A -> B -> A ....

So the general advice is to use “return” type Links sparingly.

1 Like

Interesting… I am new to Twine so thanks for your wise words.

I guess thinking ahead the player in my game-story has lots of navigation option available. Back button might be redundant enough to remove given potential confusion on the players part.