I6: Hyperlinks in Glulx

Cool! :smiley: That means it was working nicely for me 'cause my terp was acting in an illegal way! :stuck_out_tongue:

OK, as I said, I’ve been trying with this glk_set_echo_line_event() function (which I checked was supported in my Windows Glulxe)(remember to get the latest infglk.h, not the one in the IF Archive but the one in zarf’s github thing). Almost there…!

It happens that, as documented in the GLK 0.7.3 API specification that Ben linked (here), this function only works in subsequent line input requests… So the line break would be there when you catch the hyperlink event but won’t appear in subsequent turns… Of course in these subsequent turns ordinary behavoiur is overidden by this save you turn it off, which would then have an effect not in the current turn, but in the following ones…

Save I’m missing something, this make this feature very useful if you know in advance that your work is meant to be used exclusively in one or the other mode, but not if both are supposed to co-exist and you can’t predict wether the player is going to type or click.

Still I do hope I’m missing something…

As a practical matter, you would want to turn off the echo when the game starts. Then just print the player’s input after line input events - it comes back to you in the event struct - and discard it when you cancel the line input request.

Example code here; demo here.

Would it be pushy to ask someone to wrap this up in a nice I7 extension when it’s all ironed out? Because that would be great.

There are already three or four I7 extensions that offer the basic hyperlink functionality, including the ability to link a command that is different that the linked text (e.g., clicking on the text “north” to produce “go north”). What all of them are missing, though, is the new echo functionality to fix the default line break that accompanies a canceled input event. I second the request for an extension or a demo of that for I7…


Aha, thanks!
That linked example is not in the format of an actual game and makes its glk calls with numbers instead of meaningful names (which are luckily mentioned after that in comments) so yeah, I’m having the mother of all headaches right now :laughing:, but I guess I have a working (and hopefully not based on an illegal feature if WinGlulxe) example:

!% -G
!% -D

Include “Parser”;
Include “Verblib”;
Include “Infglk”;

Object Room_01 “Room 01”
print "You’re in Room 01. An exit leads ";
print “NORTH”;
print_ret “.”;
n_to Room_02,
has light

Object Room_02 “Room 02”
description “You’re in Room 2”,
s_to Room_01,
has light

lookmode = 2;

[HandleGlkEvent ev context abortres newcmd cmdlen;
switch (ev–>0)

		newcmd="go north";
		return 2;


glk_put_buffer(buffer+WORDSIZE, buffer–>0);

Include “Grammar”;[/code]

It’s probably too late to help Jim, but I didn’t want to just forget about it. What it does is:

-Sets echo off at the begining of the game.
-Uses the line input event to manually print the contents of the player input (calling the Command_printing routine)
-After a click is detected, its command is also printed calling the same routine.

Seems to work, though I’ve hardly tested it! ^_^’ any contraindication or just something that could go wrong with this?

Far from being offended by this unintentional slight, I’m amused. I agree – I’m quite beyond help!