Skip to content

Instantly share code, notes, and snippets.

@Blecki
Created June 16, 2013 16:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Blecki/5792481 to your computer and use it in GitHub Desktop.
Save Blecki/5792481 to your computer and use it in GitHub Desktop.
Version 1 of Generated Hyperlinks (for Glulx only) by Anthony Casteel begins here.
"based on Basic Hyperlinks by Emily Short and Inline Hyperlinks by Erik Temple"
Include Glulx Entry Points by Emily Short.
Include Text Capture by Eric Eve.
Section - Glulx Interaction
When play begins:
start looking for hyperlinks.
To start looking for hyperlinks:
(- SetLink(); -)
To say set link (N - a number):
(- if (glk_gestalt(gestalt_Hyperlinks, 0)) glk_set_hyperlink({N}); -)
To say terminate link:
(- if (glk_gestalt(gestalt_Hyperlinks, 0)) glk_set_hyperlink(0); -)
A glulx hyperlink rule (this is the default hyperlink setting rule):
perform glulx hyperlink request.
To perform glulx hyperlink request:
(- if (glk_gestalt(gestalt_Hyperlinks, 0)) DoLink(); -)
Include (-
[ DoLink;
setlink();
playHyperlink(gg_event-->2);
];
[ playHyperlink n;
(+ current link number +) = n;
if (n > 0) {
glk_cancel_hyperlink_event(gg_mainwin);
FollowRulebook( (+ clicking hyperlink rules +) );
SetLink();
};
];
[ Setlink ;
if (glk_gestalt(gestalt_Hyperlinks, 0)) glk_request_hyperlink_event(gg_mainwin);
];
-)
The clicking hyperlink rules are a rulebook.
Current link number is a number that varies.
A clicking hyperlink rule (this is the command replacement by hyperlinks rule):
Say "The current link number is [current link number]";
If the current link number is less than the number of rows in Table of Hyperlink Glulx Replacement Commands:
Now the glulx replacement command is the replacement in row current link number of the Table of Hyperlink Glulx Replacement Commands;
Otherwise:
Now the glulx replacement command is "";
Rule succeeds.
Section - Table of Hyperlink Glulx Replacement Commands
[Expand this table to have at least as many entries as the number of links that will appear on the screen at once]
Table of Hyperlink Glulx Replacement Commands
replacement
some indexed text
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
--
Section - Generating hyperlinks
The current hyperlink row is a number which varies. The current hyperlink row is 1.
The created hyperlink is a number which varies.
To create a hyperlink from (text - some indexed text):
Now the created hyperlink is the current hyperlink row;
Now the replacement in row created hyperlink of the Table of Hyperlink Glulx Replacement Commands is text;
Increase the current hyperlink row by 1;
If the current hyperlink row is not less than the number of rows in Table of Hyperlink Glulx Replacement Commands:
Now the current hyperlink row is 1.
To say link from (text - some indexed text):
Create a hyperlink from text;
Say "[set link created hyperlink]".
Section - Saying hyperlinks
The hyperlinked text is an indexed text variable. The hyperlinked text is "".
The hyperlinked command is an indexed text variable. The hyperlinked command is "".
To say link:
now the hyperlinked text is "";
now the hyperlinked command is "";
start capturing text.
To say as:
stop capturing text;
now the hyperlinked text is "[captured text]";
start capturing text;
To say end link:
Stop capturing text;
If the hyperlinked text is "":
Now the hyperlinked text is "[captured text]";
Now the hyperlinked command is "[captured text]";
Say "[link from hyperlinked command][hyperlinked text][terminate link]";
Section - Testing Generated Hyperlinks (not for release)
Testing the link mechanism is an action out of world applying to one thing.
Understand "link [something]" as testing the link mechanism.
Carry out testing the link mechanism:
Let T be some indexed text;
Now T is "link [noun]";
Say "[link from T][T][end link].".
Viewing the link table is an action out of world applying to nothing.
Understand "links" as viewing the link table.
Carry out viewing the link table:
repeat with N running from 1 to the number of rows in the Table of Hyperlink Glulx Replacement Commands:
If there is a replacement in row N of the Table of Hyperlink Glulx Replacement Commands:
Say "[N] - [replacement in row N of the Table of Hyperlink Glulx Replacement Commands].".
Generated Hyperlinks ends here.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment