Can Inform trigger AppleScript events or otherwise communicate with an Arduino?

Hi there,
I have no experience with Inform but am excited by its potential. I have a project for which I’m considering Inform and I’m wondering if Inform can be used to trigger AppleScript events? Perhaps with an extension? Ultimately, I want the player’s actions to trigger events external to the computer, via an Arduino, but I figured AppleScript would be the likely intermediary in such an interaction.

Anyone know of a way to get Inform to trigger AppleScript events or otherwise communicate with an Arduino board?
Thanks!
Scott

Easiest way to do this is probably to use something like RemGLK and communicate with your story file through the terminal. Imagine an outside routine “playing” your Inform game and relaying its data. That’s how I’d do it, I think.

Inform games run on a virtual machine with very limited contact with the outside world. So if you want to make something happen on an Arduino, you’ll have to work through one of the VM’s existing communication channels.

If you use RemGlk or such, as Eleas suggests, that would involve putting something in between the VM and the user, looking at I/O as it goes past and responding appropriately. This is what Vorple does: it adds an extra output stream, then takes anything that’s sent to that stream and executes it as JavaScript.

Another option is to have the Inform game write messages out to a file, which an external program watches and reacts to. This is probably easier, on a technical level, since you can leave all the game/player interaction to the interpreter without having to care about it. However, you also have to deal with polling and such.

2 Likes

Just as a quick addition: if you go for the second option which Draconis mentioned, you can find some documentation and examples in the Inform Manual, sections 23.11 (“Files”) to 23.15 (“Exchanging files with other programs”).

Hi Eleas, Draconis, and StJohnLimbo, thank you for your suggestions! I’m imagining that Inform sending a message to an Arduino or Raspberry Pi to do something would probably be easier than communication in the other direction. As a rather crude method, I was thinking of using Vorple Multimedia to play an audio file that players wouldn’t hear, but that a second computer would be listening for and would convert the sounds (via speech-to-text or using tones of varying frequencies to mean different things) to commands that are sent to the Arduino. The part that I’m struggling with a bit more is communication in the other direction. So the user solves a puzzle in the real world, which is detected by the Arduino and it somehow (pun intended) informs Inform 7 of the change in state. Is it possible to manipulate the game’s database from the back end directly via a script? Or is that what Eleas meant by communicating with the game via the terminal? Can the database be manipulated in the background while the user is playing the game? I’m imagining, as an example, that the player reaches a part of a map where it’s dark. But in the real world, they find a fuse box that’s got a burnt out fuse and the replace the fuse. The Arduino does a continuity check, verifying the fuse is in place, and then changes the state of the lights in that section of the map to indicate they are on.

Thanks again for your help! I hope I know half what you know about Inform at some point in the future. I’m very excited about working with it.
Cheers,
Scott

I wouldn’t do it this way. Just too many ways for things to break down or go wrong.

For your use-case, I’d recommend using files for communication. Nice and simple, requires no custom interpreter, and no needing to convert text to audio, play the audio, listen for it on a microphone, convert it back to text, and interpret it. Just have Inform write to a file, which your other program reads and reacts to, and vice versa.

2 Likes