Please specify version and format if asking for help, or apply optional tags above:
Twine Version: 2.3
Story Format: SugarCube 2
So I’ve got a bit of an idea I’d like to implement for my story, and I’ve figured out how to mostly make it do what I want, except I’m running into issues related to the title of this post.
The short version of what I’m trying to accomplish is: I want to have multiple links throughout the story that will take the reader to a separate dedicated passage, which gives them more information about whatever entry they clicked on, and at the same time “unlocking” that passage in a master list of passages that default to “locked” until seen once by the player, and finally allow them to return to the location in the story they were at before clicking the link.
So to explain what I’ve done already in more detail, I have another passage that’s linked from the main title screen of the story called simply “Encyclopedia” which starts out with all entries “Locked” by default. I have a simple if statement in place that checks to see whether or not a unique variable associated to each entry is True or False, with a message that says: “Read the story to find out more about this entry!” by default when set to False, and when set to True, it displays that unlocked Encyclopedia entry instead.
As the player reads the main story, each time they click on one of those story links and are taken to the specific entry’s passage, I also want to have it unlock that entry from the Encyclopedia. That way they can easily reference any of their unlocked entries right from the title screen.
So far I’ve managed to accomplish this using a combination of Setter Links in the story to set the entry specific variable to true when a given link is clicked on, and on the individual passage dedicated to each story link I’ve added the
<<remember>> bit of code to toggle simple ON/OFF boolean checks in these variables to see if the player has visited a given passage yet or not.
So an example Setter Link I’m using just to test functionality of a story link looks like this:
[[Sample Text Variable 1|Sample Variable 1 Passage][$testcase1 = true]]
And on the resulting story passage test page I have a placeholder text message for now that will eventually be the same entry as in the Encyclopedia listing, and the passage starts with the following code:
<<remember $testcase1 is true>>
I then added a simple link at the bottom of each individual entry’s passage in the story to “Click here to return to the story” which sends them back to the passage they were at before clicking the story link.
All of the above is working as I have intended. However, the problem I am running into is that, if the user ignores the link that takes them back to the story, and instead uses the Back Navigation button built into the UI menu, the natural functionality of that button causes Twine to essentially “forget” that the unlock variable was set to true.
So the reader who uses the back history button returns to the story after reading the story link’s passage, but without unlocking the associated Encyclopedia entry because the variable doesn’t stay “remembered” like it did when using the “click here…” link, which I’m guessing is because the engine sees that link clicking action as moving forward rather than the stepping-backward functionality of the UI button.
One idea that I imagined might work as a possible solution to this was temporarily disabling the back history button’s functionality in the UI just on the specific passages after clicking each of these story links, and then re-enabling it on returning to the main story. I found some resources and seemingly simple-to-implement solutions about disabling the functionality of the back button completely, but I’m less keen on that idea, as I’d like for it to still work elsewhere in the game if possible.
The other idea that I thought of was the more obvious and ideal solution of getting Twine to somehow remember the state of the boolean variables as being set to True regardless of whether or not a link was used or the back button was used to navigate, and I wouldn’t be surprised if it was something simple that I am unaware of or simply overlooking.
I haven’t had any luck so far finding information about either of those things though. It’s highly possible I am implementing something incorrectly or making a simple error in my lack of understanding and experience. So I figured I would ask for help and see if anyone could steer me in the right direction.
I’m a new user to Twine in general and the forums as well, with next to no prior HTML/CSS knowledge, so your patience is appreciated, as is any information or directions folks might be able to provide for this. Thanks in advance for your time.