Achieving Real-Time Delays with Vorple

Hello! I’m working on my first Vorple (and Inform 7) project and was wondering if anyone could provide tips on this. I’m aware that Erik Temple’s Real-Time Delays extension doesn’t work when using the Vorple interpreter, and I would like to achieve the same effect using Vorple.

Specifically, I want to be able to add an in-line instruction like wait X ms before continuing between say instructions, and have the game pause briefly before outputting the next text and/or the command prompt. I see this input filter example in the Vorple docs and wonder if it can be adapted to do exactly this, but I’m getting a browser error when loading with this whole snippet inside an execute JavaScript command:

Quixe init: Error: JavaScript code from story file threw an error: Unexpected token ')'

My alternate idea was to try using an output filter to 1) store a given output to a variable, 2) set that output to "", 3) ‘restore’ the output to that variable after a setTimeout. Not sure if this makes sense or if input filters are really best. It also seems like knowing when to hide/show the command prompt would get tricky in this case. I’d paste my WIP code here, but it’s half-baked and I thought I should ask whether to focus on input vs. output before going deeper into using output filters.

Any tips would be very much appreciated! I’m semi-okay with basic JavaScript, but it’s murkier for me now that I’m touching the Inform 7 input/output behavior. (I also saw this previous thread on the topic, but it looks like the example Juhana provided is doing something different.)

1 Like

Hi there! Welcome to the forum :slight_smile: I may be able to help but I’m not sure I understand the question but I hope this helps!

I re-read your post and think I have a better idea of what you have in mind. Here is a working example that inserts a 1 second pause into the text output any time it sees the token “=!;”:

It isn’t perfect, for one there is a slight flicker because first, all of the text loads, then it is intercepted by the HTML event listener and reprinted with the pauses. I wasn’t able to sort out a better way to do it, I suspect one could hide the flicker with CSS sleight-of-hand.

Hopefully this gets you started?


Hi Joshua, thank you very much! I think this is what I’m looking for, but would need to mess around a bit. Is there a way that I can view your source for that demo?

Glad to hear it :slight_smile:

The tricky part is the javascript in the /play.html link above, let me know if you have trouble viewing source on that from the browser.

As for the I7 src, here’s a link:

Good luck!

1 Like

So, this is lovely to use, and I very much appreciate the commented code. This is definitely a more extensive solution than I expected to need, but it looks just right.

I’m using a dynamic gradient as a background, so I decided to toggle the text opacity from 0 to 1 instead of switching colors. Haven’t noticed any flicker.

I added some randomness in the timing; the idea is to emulate the tiny pauses one used to experience when using DOS, or the longer pauses when waiting for processes to complete on a terminal. Lastly, this code caused the story to stop scrolling to the prompt, so I added a couple scrollIntoView lines to have the text unfurl as it goes. It’s looking really nice so far.

Thank you again!

1 Like