Hi all,
So the problem I am facing is that in CH 1 of my game you set your name $name. And it persists till the last CH 4.
In the last CH 4, I want to give people the option to go back and play any of the Chapters e.g. 1,2,3.
If I send them back from CH 4, will the $name persist, or will it be gone if say, the player goes from CH 4 to CH 3?
If $name does not persist as set in CH 1....what's the solution here. The only terrible workaround I've come up with is to ask players if they would like to redefine their $name at the start of each CH.
Help?
Comments
Generally once a variable has been assigned a value that variable (and it's value) is available to every Passage displayed to the Reader from that point on including the Passage that the assignment was done in.
If you move the Reader forward from the last passage in your story to the first passage then the variable will still have value it had in the last passage, unless the first passage contains code that changes the variable's value.
This is one reason why it is not a good idea to assign default values to your variables within the first passage, both Harlowe (startup tagged passage) and SugarCube (StoryInit special passage) support initializing variables at Story startup.
If you use some other means (like reloading the page, rewinding History, etc...) to return the Reader to the first passage then the variable may not have same value it had in the last passage.
Naming a passage StoryInit has no special meaning in Harlowe, but if you also assign it a startup tag (all lower case) then it automatically be processed before the main/first passage is shown to the Reader.