An author's reference for Bisquixe, a tool for adding audiovisual content to Inform projects (up: final (?) comments on Cloak of Darkness)

More advanced applications of hyperlinks

Working from the perspective of handling hyperlinks as text immediately reveals opportunities. Perhaps we would like to treat every noun in a room description as a hyperlink that causes a game to examine the think referred to. We can do this by using the printing the name of something activity.

Note that, when we are dealing with text rather than things, we always invoke the printed name of [something] rather than just [something] by itself. Consider this example:

lab is a room.

include simple multimedia effects for v10 by mathbrush.

release along with a "bisquixe" interpreter.

when play begins:
	css-set-fast "a:link; color; blue";

[************]

rule for printing the name of a thing (called the widget):
	hyperlink "[the printed name of the widget in upper case]" as "examine [the printed name of the widget]";
	
[************]

the decorative bust is scenery in lab.
the beaded curtain is scenery in lab.

the description of lab is "This rather tastlessly decorated laboratory features a hideous [beaded curtain] as well as a poorly-constucted [decorative bust].

Just being here gives you a headache."

Note that these links will print in upper case letters for legibility’s sake.

Our rule generating the hyperlink text deals with printed names, while the actual name of a thing refers specifically to in-game things.

To leverage this example, we need only encapsulate the name of a thing in our text to generate the relevant hyperlink.


We can go further. Perhaps we would like to hyperlink exits mentioned in the texts of our room descriptions:

rule for printing the name of a direction (called the way):
	hyperlink "[the printed name of the way in upper case]" as "go [the printed name of the way]";

Alternately, building off of our rule for printing the name of a direction, we can use a list to create a simple exit lister with hyperlinks.

last after looking:
	let X be a list of directions;
	let command be a text;
	repeat with way running through directions:
		if the room way of the location is a room:
			add way to X;
	if the number of entries in X is zero:
		say "Unfortunately, there seems to be no way out.";
	otherwise:
		say "[bold type]Available exits:[roman type]";
		say line break;
		say x;
		say line break;

Note that links remain onscreen even after they no longer apply, such as when a player leaves a room. Depending on the context, that can be confusing. Some alternatives will be discussed in sample “recipes” once this reference is complete.

We can add hyperlinks to a list dynamically. Perhaps we wish to add links to a list based on whether or not they seem applicable.

the cmdBar is a list of texts that varies.

to say tk:
	hyperlink "taking something" as "take";
	
to say ex:
	hyperlink "examining something" as "examine";
	
to say drp:
	hyperlink "dropping something" as "drop";

last after looking:
	truncate cmdBar to 0 entries;
	if there is a portable thing (called the widget) in the location and the widget is not the player, add "[tk]" to cmdBar;
	add "[ex]" to cmdBar;
	if the player encloses something, add "[drp]" to the cmdBar;
	say "Possible commands include [cmdBar].";


Note that adding hyperlinks to a table is not possible without a bid of dark magic. I’ll discuss an approach to this in the “recipes” section below.

The bottom line is that while hyperlinks are easy to implement, their capabilities are readily extended via CSS, text substitutions, and lists.

2 Likes