Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Adding an undo button to Snowman 1.0.2

Hi everyone - new to Twine here.

I'm trying to publish my Twine story in a responsive format (meaning it looks pretty when viewed on desktop, mobile and anything in between). For that reason, I'm trying to work with the Snowman format, as the default Harlowe style renders text too small on mobile.

Snowman seems closest to what I want, but the default snowman style doesn't have the undo/redo buttons that Harlowe has. Could someone help me in implementing an undo button? I've googled to the best of my abilities but to no avail.

As background, normally I can hack around okay in HTML and CSS, but I'm struggling to get the results I want with Twine. Maybe it's the twine-specific stuff I don't understand, or maybe it's all the JS and jQuery.

Any help would be appreciated. Thanks.

Comments

  • Showman does not have it's own undo feature/method, it instead uses the web-browser built-in history (Back/Forward buttons) to handle moving backward and forwards.

    You can use Javascript to also move through the browser history.

    Use something the following to show a link that will move the Reader back one passage:
    <a href="javascript: window.history.back();">Undo</a>
    
  • If you'd like to add an entry to the browser history every time a reader visits a new passage, add this to your story JavaScript:
    $(window).on('showpassage:after', function (e, data)
    {
        window.story.checkpoint(data.passage.name);
    });
    

    If you'd like to do this only with passages that are tagged 'checkpoint', use this instead:
    $(window).on('showpassage:after', function (e, data)
    {
        if (data.passage.tags.indexOf('checkpoint') != -1)
            window.story.checkpoint(data.passage.name);
    });
    
Sign In or Register to comment.