Hi there,
I'm working in Twine 2.0 with Harlowe.
I'm want to allow the player a certain amount of time in a passage, and if they don't move on out of it on their own, to redirect them to a new passage.
I'm guessing i want to call Harlowe's Engine.gotoPassage function - although i don't seem to be able to access the Engine
The following code produces the error:
<script>
$(document).ready(function(){
$("#debug").delay(5000).each(function(){Engine.goToPassage(startPassage);})
});
</script>
so i'm guessing this might be something to do with scope. Or something - I don't know... Or possibly I'm going about this totally wrong.
Thanks in advance for any help...
Comments
Although there are ways to increase the scope of Harlowe's Modules using hacks like the following: ... I would strongly suggest not relying on them as any changes to/restructure of those internals could result in your story no longer working.
I personally don't like supplying solutions that rely on undocumented features/effects because they can then become the accepted way to do something, and the history of software developing has many examples of where using them has come back to haunt the developers. Parsing the Windows version string to determine the series of an instance of Windows is one famous example.
SugarCube also has a documented Javscript API which supports programmaticly showing a passage.
One potential User Experience issue with redirecting based on real time in a Text based medium is that people read at different speeds (for a number of different reasons).
I know that I would be slightly annoyed if I was part way through reading an interesting piece of text only to have it disappear without any warning.
(i totally get it about different reading speeds - i'm trying to make something which plays with transience and the frustration of things slipping from your grasp and with text as fluid rather than fixed - and which will also have a feeling of things running on regardless if you don't interact with it. i get that there's access issues with this - once i've got a prototype up and running i think i'll play with allowing people to vary the speed it runs at.)
Thanks again.
Here's how it works in Snowman:
EDIT: this needs a bit more thinking through - as we need to clear the queue when we leave the passage so that it doesn't redirect itself - i suspect this will be done using the "hidepassage" event to clear the queue on the document every time we click through to something new... I'll update this post when i've figured it out in case anyone else ends up here with this question.
EDIT 2: this bit of code in the Story Javascript should do it (although it'll also clear anything else that's queued up at the document level)