Here's a slightly more interesting question. I'm attempting to set up a text link so that when the player clicks the word "east" in the room description, the command "go east" (followed by a Return) will appear on the command line of the interpreter, with the expected result.
It's not working yet.
The link appears correctly in the terp. Here's the code that sets it up:
Code:
[link_set dir;
switch (dir) {
E_GOING: glk_set_hyperlink(E_GOING);
print "east";
glk_set_hyperlink(0);
};
];
Room study "Your Study"
with description [;
print "There is a doorway to the ";
link_set(E_GOING);
" of this austere room.";
],
e_to hallway;
Here's how I'm trying (and failing) to handle the click on the hyperlink:
Code:
Constant E_GOING = 1;
Constant W_GOING = 2;
[ HandleGlkEvent ev context abortres newcmd cmdlen;
switch (ev-->0) {
evtype_Hyperlink:
glk_request_hyperlink_event(gg_mainwin);
glk_cancel_line_event(gg_mainwin, 0);
if (ev-->2 == E_GOING) {
newcmd = "go east";
cmdlen = PrintAnyToArray(abortres+WORDSIZE, INPUT_BUFFER_LEN-WORDSIZE, newcmd);
abortres-->0 = cmdlen;
glk_set_style(style_Input);
print "go east";
glk_set_style(style_Normal);
new_line;
}
}
];
What this does is, when I click on the link, the words "go east" are printed on the line BELOW the prompt, the input cursor remains on the line with the prompt, and input is dead. The game no longer accepts typing input.
I'm trying to use the explanation on the Gull pages. I think I've copied the code exactly. Adam says those lines are supposed to do the job. But they don't. Since I can't find a reference to PrintAnyToArray in the DM4, I have no idea what it's doing. I'm stumped.
--JA