Can I deactivate previously printed Glulx hyperlinks?

I want to deactivate a hyperlink once it has been used so that one-time-use commands cannot be clicked again, causing confusion (instead of convenience) for the player. I’ve been unable to find a way to do this.

For example, is there code I could add to the DeactivateHyperlink routine below to disable all instances of the hyperlink id LINKID_JUMP?

Constant Story "Link Test^";
Release 1;

Include "vorple.h";
Include "parser.h";
Include "verblib.h";
Include "infglk.h";

Constant LINKID_JUMP 1;
[ HandleGlkEvent ev context abortres newcmd cmdlen;
    switch (ev-->0)
    {
    evtype_hyperlink:
      glk_request_hyperlink_event(gg_mainwin);
      switch (ev-->2) {
        LINKID_JUMP: newcmd = "jump";
        default: newcmd = 0;
      }
      if (newcmd ~= 0) {
    		glk_cancel_line_event(gg_mainwin,0);
    		cmdlen=PrintAnyToArray(abortres+WORDSIZE,INPUT_BUFFER_LEN-WORDSIZE,newcmd);
    		abortres-->0=cmdlen;
    		return 2;
      }
      glk_cancel_line_event(gg_mainwin,0);
    }
];

Include "grammar.h";

[ Initialise o;
    location = lab;
    glk_request_hyperlink_event(gg_mainwin);
];

[ DeactivateHyperlink;
  "Sure would be nice if that link were deactivated now.";
];

Object lab "Lab"
  with
    jumpcount 0,
    description [;
      print "Where the sciencing happens.  Ready to ";
      glk_set_hyperlink(LINKID_JUMP);
      print "jump";
      glk_set_hyperlink(0);
      "?";
    ],
    before [;
      Jump:
        print "Incrementing jumpcount.^";
        self.jumpcount++;
        if (self.jumpcount >= 1) {
          DeactivateHyperlink();
        }
        if (self.jumpcount > 1) {
          "You have exhausted your allotment of jumps.";
        }
    ],
  has light;

You can’t deactivate specific hyperlinks. What you can do:

  • Turn off all hyperlink events. Depending what you’re doing this might just be enough.
  • Clear the window and reprint without the hyperlink. A good solution if the hyperlink is in a side window.
  • Track the state of your hyperlinks manually and ignore any events for hyperlinks that have already been used.
1 Like