Update: this is now built into Twine 1.4, so this script is no longer necessary. You can enable it in Twine 1.4 by writing "Undo: off" in StorySettings.
If you want to remove the browser's Back button functionality in Sugarcane, to prevent the player from rewinding or undoing moves, here is some script code that can do that.
Obsolete script removed: use Twine 1.4
Version history:
Comments
useful!
I had been looking for a way to do this, but my attempts to comment-out everything modifying the url hash were pretty disastrous.
Ahaaaa! Thanks muchly for
Ahaaaa!
Thanks muchly for this, i've been wanting to find out! (btw you should just collect all of these posts into a big pdf or something)
Hey I am having problems
Hey I am having problems getting this to work, in fact I can't get any functions that you have posted to work properly which makes me think I am missing some sort of vital information on how to properly set them up despite looking at several tutorials.
Here is what I have in my start panel;
You can see I am using both your 'eliminate back button' code and the one that allows the '\' key to eliminate line breaks, but neither work in my story. (The '\' key actually results in '\s')
Any direction would be greatly appreciated for a brand new Twiner!
Hi! Javascript code doesn't
Hi!
Javascript code doesn't generally go in the "Start" panel, it goes into a special passage with "script" in its tags. So if you create a new passage, put "script" for its tags field, and paste everything between "set $cavestate = 0" and "endsilently" into that, you should be set.
(Basing this answer off of the Twine FAQ; I technically haven't actually tried to do any JS in Twine yet.)
Thanks so much, champion!
Thanks so much, champion!