Basic Hyperlinks

version 3 by Emily Short

  • Home page
  • Complete text



  • Version 3 of Basic Hyperlinks (for Glulx only) by Emily Short begins here.

    "Allows the author to set hyperlinks in the main window and give instructions about what is to result from performing them."

    Include Glulx Entry Points by Emily Short.

    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 end 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 default command replacement by hyperlinks rule):
        repeat through the Table of Hyperlink Glulx Replacement Commands:
            if the current link number is linknum entry:
                now the glulx replacement command is replacement entry;
                rule succeeds;
        now glulx replacement command is "".


    Table of Hyperlink Glulx Replacement Commands
    linknum  replacement  
    a number  some text  

    Basic Hyperlinks ends here.