0 votes
by (510 points)
I'm making a heavy choice-based story and I don't want readers to be able to cheat and change their choices if they get a bad result by just hitting the back button and selecting a different choice, but I also don't want to eliminate their ability to reread passages if they want to. Is it possible to do this?

1 Answer

0 votes
by (159k points)
selected by
 
Best answer

There is a conflict in your request that needs to be resolved.

When the Reader selects the Undo (Back) button they are winding History back one moment in time, this cause the story's state to return to what it was before the previously seen passage was last displayed, and any logic ($variables) contained within that passage is processed. It is like they never viewed that passage previously.

You could include manual links within your passage content that reference the previously displayed passages but doing that also has downsides:
a. The logic in the revisited passages will be re-executed unless you implement some means to stop it from happening.
b. The Reader will be able to select the standard links on the revisited passage unless you implement some means to make them read-only (unselectable)

Question: In a normally play-through of your story (without the requested ability of retracing steps):
a. does each passage only get displayed once.
b. or do passages get re-visited and they content dynamically changed for each visit?

by (510 points)
a. Not sure, but it's unlikely. There might be some degree of exploration involved which would be easier to do if I could reference the same passage continually.

b. Once again, possibly for same reasons as above.

Is it perhaps possible to have variables that function independently of the history buttons? In other words, variables that don't get wound back? If so I could use those to "grey out" the other options with if statements.
by (159k points)

SugarCube includes a setup object which you can add variables and functions to, anything added to the setup object is not part of the History system nor is it included in the Save system. The setup object is accessible in both Passages and Javascript.

NOTE: This means that values stored in the setup object will not be automatically reset during an Undo or a Load.

So you could do something like the following:

/% Assign a value in a Passage. %/
<<set setup.haveDoneSomething to true>>


/% Check is something has been done in the same or another Passage. %/
<<if setup.haveDoneSomething>>...you did something...<</if>>

 

by (510 points)
Excellent, this will work wonderfully, thank you!
...