0 votes
by (160 points)

    You are Long John Silver from the book <i>Treasure Island</i>.

    <code>Press ENTER to continue...</code>

        document.addEventListener("keypress", function(event) {
        if (event.keyCode == 13) {

Why does this not work?


I have been searching all over the web for 3 hours, so it would be nice if somebody found a solution.

1 Answer

+1 vote
by (159k points)
selected by
Best answer

You need to state the name and full version number of the Story Format you are using, as answers can vary based on this information.

As far as I know none of the story formats (that come pre-installed with the Twine 2.x application) support using the web-browser's Location object to navigator between Passages.

Harlowe: This story format doesn't have a documented JavaScript API, and it is deliberately designed to restrict an Author's access to its JavaScript based engine.

SugarCube: You can use this story format's Engine.play() function to programmatically cause the story to move to another Passage.

Snowman: You can use this story format's story.show() function to programmatically cause the story to move to another Passage.

by (160 points)
How do I get the story format?
by (44.7k points)

Assuming you're using Twine 2, you can set the default story format on the main Twine page using the "Formats" button on the right side.  Or, in the story itself, you can open the bottom-left menu and select "Change Story Format" to set that one story's story format.

Generally speaking, I'd recommend using the SugarCube story format (documentation here).  That said, you'd probably want to change your <script> element to using a <<script>> macro instead.  You could also switch to using Twine style markup as well.

Hope that helps!  :-)