(Auto) Saving with Glulxe and RemGKL

Hey y’all!

I’m in the process of building a way to play IF on Slack. For Glulx games, I have a Node JS app that communicates with Glulxe (compiled with RemGLK) via STDIN and STDOUT. This seems to work pretty well so far, but I’m having trouble with saving.

Right now, I’m getting a segfault when I try to send the terp something like: {"type":"line","gen":3,"window":21,"value":"save" }

But ideally, I’d like auto-saving and auto-restoring, kinda like what’s described here: eblong.com/zarf/glk/terp-saving-notes.html

So, couple questions:

  1. Is there a way to compile Glulxe/RemGLK so that saving or (better yet) auto-save/restore are possible? (bearing in mind that I’m not a very good C programmer)

  2. Am I doin’ it wrong? Is there perhaps a different RemGLK-friendly interpreter that I should try that might be a better fit for my case?


You shouldn’t get a segfault there, obviously. You’ll have to go in with a C debugger to determine the problem.

The library should come back with a “{specialinput: …}” update, to which you respond with “{type:specialresponse, …}” and a filename. I don’t remember the exact syntax. Floyd/sleepmask uses this, so I know it’s possible.

As for auto-save: you are on the right track, but unfortunately the right track is unpaved. Autosave has never been implemented for RemGlk, only for IosGlk (Objective C) and GlkOte (Javascript). This is a fair chunk of work, unfortunately.

I can’t be as useful as zarf here, but a couple things:

Check out the glkote docs for info on the protocol format. You might want to look at the fileref_type and specialresponse types, as I suspect that your problem might have something to do with being prompted for a filename during a save.

From what I’ve seen of the glulxe code, it only supports autosave on iOS. See the iosstart files and iosglk. I think this is because, as the doc you linked says, most of the work for autosave is in the glk library. I don’t see any autosave support in remglk. If you’re willing to work on your C skills, you might want to look at iosglk and think about how you could port the autosave feature to remglk.

Edit: The authoritative zarfian reply came back while I was composing this.

The iOS autosave code relies heavily on NSKeyedArchiver, which is a standard iOS/MacOS toolkit for serializing data. Recreating that in plain C would require some library to do the same thing.

There might be something in the C++ standard library.