Therefore, I have jammed Z-machine support into Lectrote. It’s not pretty, but it lets you play games.
The biggest lack is saving. You can’t save. Or rather, you can save, but the save data is just stashed in memory. No save file on disk! When you close the game window, poof, it’s gone. And you only get one save slot anyhow.
Why? Because I shoved Parchment in there, and I haven’t had time to adapt it to real save files. I will try to improve this tomorrow. (Spoiler: autosave still won’t work.)
There are a bunch of other rough edges, mostly having to do with window size and font size. See the release page for all the caveats.
JSZM is other Z-machine implementation with JavaScript. It supports save games using a Uint8Array (it also expects the game to be loaded as a Uint8Array); in Node.js you can then use Buffer.from(x.buffer,x.byteOffset,x.byteLength) or new Uint8Array(x.buffer,x.byteOffset,x.byteLength) to convert between Buffer and Uint8Array. However, JSZM requires ES6 support (recent versions of Node.js support it, but I don’t know about Electron).
Also, your README file says doesn’t support Z-machine.
Electron does support ES6. However, I am sticking with the Parchment implementation because I know how it works and I was able to get it jammed in quickly.
You’re right, I forgot to update the README. I will fix that today. Thanks.
Although no longer relevant to this, I can write here some suggestions that may be useful in future in case someone tries to do something a bit similar with save files in JavaScript.
If the module you are using provides save game data as a ArrayBuffer or Uint8Array (as JSZM does, for example), then it will be easy to save to or load from a file. I don’t know how Parchment works, but apparently it does not even use typed arrays (was it written before JavaScript had them?).
Also recently I have written a Node.js package called “object-serializer” which is used for serializing arbitrary JavaScript values (well, almost) in a binary file; although, it is design better for games written in JavaScript rather than stuff like Z-machine (but still could be used for such if you really need it).
Also, I have looked at your files and find it says “Z-Machine (versions 5 and 8)”, so it may still be useful to include JSZM in addition to (not instead of) Parchment, since they are for different Z-machine versions.