I started trying Dialog recently, and it’s possible I like it better than Inform 7. However, I also like Vorple a lot, at the point that not having Vorple for Dialog is a blocker for me. So I’m considering if it’s possible to create something like Vorple for Dialog.
Here are some thoughts. (It’s a long and a bit technical post, so you may ignore it if you don’t need this kind of features.)
I took a look at the Å-machine web interpreter, and since the engine and the front-end are nicely decoupled (I always found Quixe and its Glk API a bit tangled and complex), I think it should be possible to write a custom Vorple-like front-end. But for that, two things need to be solved.
First, sending JS commands to the webpage. I thought about using a (inline) status bar with a special class, in which we output our JS code. The Å-machine front-end would hide it and watch its content to execute it. We could maybe use a div or a special markup in the output (
[JS]alert("Hello")[/JS]) instead, but a status line doesn’t end up in the transcript and seems easier to handle.
Second, retrieving the returned JS value. This one is more tricky. I suppose we could ask for a line input just after sending a JS command, and the front-end will send back an input just after executing the JS command.
It would be something like this, Dialog-wise. It’s written quickly and untested, it’s just to get the idea.
Issues I see for the moment:
- All the parentheses in JS commands will have to be escaped. Unavoidable, but annoying nonetheless.
- JS commands will have misplaced spaces in it. For example, Dialog will automatically insert a space before the parenthesis of a function call except if we use
(no space). Mostly harmless, but I suppose it can cause strange issues sometimes.
- There might be misplaced line and paragraph breaks after executing a JS command? For example, in Vorple, there is a function that redirect all output to a given HTML element; we’d have to track if a paragraph break is pending for each of these elements, or be very careful otherwise.
- Retrieving the values returned by the JS with a line input limits them to lists of dictionary words and numbers. (It won’t be possible to retrieve the exact command as it was written, with its case and white space preserved, for instance. Or it might fail if the returned value contains some unsupported Unicode characters.)
Is something like the above a good idea, and is there some interest in it? If yes, am I right to think it’s possible to implement it with the Å-machine? Have you got better ideas to communicate with the JS? (Or maybe someone is already working on something similar?)
I’ve got no plans in the near future, but I’ll likely try to implement something like that if/when I get serious with Dialog (and the possibility of a Vorple-like interpreter is a reason I might get serious with Dialog).
Thanks for reading!