This generates a command “-VISIT-NUM VAL” and processes it without printing it.
(Actually I do print “go to ROOM” while handling the action. That was a choice, though.)
The nuisance lies in the fact that you can only send integers into the game this way, not strings. Fortunately for me, the argument I needed to send was a room. So I represented each room as its Glulx object address, which is of course an integer.
Thank you for the detailed reply! I’m having trouble following the flow here. This feels like the starting point, how you would trigger the process in JS. No problem so far.
I’m not clear on what role the extevent_hook value plays. Is this documented somewhere? What calls it and what is it returning to? In glkote.js extevent just calls send_response(‘external’… and send_response doesn’t seem to call into the hook function.
I checked the release notes but couldn’t find it mentioned. Is this a builtin function in inform6? If so, where can I find documentation on it.
I was clearly looking at the wrong release notes, thank you for that link, I’ve added it to my growing collection
I’m still confused regarding HandleGlkEvent. The release notes describe it as an “entry point” similar to [Initialize;] but then it’s documented as a Glulxe-specific function that is called from within Inform6 code.
Does a call to GlkOte.extevent trigger an actual Inform6 entry-point? If so, where is that entry point documented?
It delivers a Glk event to the event-loop that the I6 library is running almost constantly when compiled for Glulx. That’s kinda the point of Glk, it’s the I/O interface between the interpreter and the story.
No. It causes the current glk_select() call to exit with specific values in the gg_event array. (This call is deep inside KeyboardPrimitive(), which is where the game is blocked waiting for line input.)
Right. This is what “entry point” means, at least the way the DM4 uses it. It’s usually defined as a Stub; it does nothing by default; you can create a routine with that name in your own code to customize library behavior.
See the release notes.
This mechanism only supports integers, I’m afraid.
You can pass 0-2 integer values. Note that these can each also be addresses of an object/string/array, but AFAIK this has to be set up on the I6 side in advance; you can’t “fill in” data on the JS side. (Well, it might not be entirely impossible, since the VM state is accessible. But it’s highly dodgy.)
If you’re looking to pass arbitrary data from JS to I6 then the way to do it is via files (possibly only using an event to signal the I6 code to read in the file).
I’ve replaced GlkOte completely in my implementation and, as far as I can tell, I’m doing everything that it would do when it comes to GlkOte.extevent.
As to extevent_hook, from reading the code it seemed like it was for processing the value passed to extevent and, since I wasn’t interested in the values right now, didn’t put it in. However, I added this code…