Howdy, Stranger!

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

Question: Linking to Specific Passage?

How do you link to a specific passage in a twine story from somewhere outside of the story?

Comments

  • My first question would be, "what format are you using?" because they all work differently. SugarCube, for example, has the ability to save a game at a particular spot, and then start the game from that point. This might solve a problem for you, no?
  • If you are using the Harlowe story format then the following hack will allow you to use a URL query parameter to indicate which passage to show when the story starts.
    note: Each story passage has an unique PID (passage id) which you will need to know before hand for the following to work.

    The following goes in your Story Javascript, it adds support for a goto parameter:

    /* method for extracting a named variable from the URL query used. */
    function getQueryVariable(variable) {
    var query = window.location.search.substring(1);
    var vars = query.split("&");
    for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
    if(pair[0] == variable){
    return pair[1];
    }
    }
    return(false);
    }

    /* if URL query contained a goto=x then show that passage on startup. */
    var goto = getQueryVariable("goto");
    if (goto) {
    Story.startPassage = goto;
    }
    The following example URL query is telling the story to show a passage with an PID of 2 at startup:
    note: the question mark indicates what follows it are parameters, each parameter is made up of a name=value pair

    http://yourhost.com/your-story.html?goto=2

    warning
    : Although the above currently works, because it is a hack there is no guaranty that it wont stop working in future versions of Harlowe.
Sign In or Register to comment.