Hadean Lands: HL Tutorial

Copyright 2014-6 by Andrew Plotkin.

This source code is provided for personal, educational use only. The story and text of Hadean Lands belong to me; you may not use them or create derivative works which contain them. However, you have permission to use the programming techniques of this game in your own works, and you may use the source code excluding game text.



Version 1 of HL Tutorial by Andrew Plotkin begins here.
 
Use authorial modesty.
 
The tutorial-phase is a number that varies. The tutorial-phase is 1.
 
Chapter - Infrastructure
 
Section - The Class
 
A tutorial-node is a kind of object.
A tutorial-node can be ever-seen. [If successfully printed.]
A tutorial-node can be open or closed. A tutorial-node is usually open. [Closed means we never consider it again, ever.]
A tutorial-node has a number called the phase-limit. [Effectively closed when tutorial-phase does not match. 0 means skip this check.]
A tutorial-node can be important. [Displayed even if the player has turned off tutorial display.]
A tutorial-node can be one-shot. [Closes itself when it displays.]
 
A tutorial-node has some text called the description. The description of a tutorial-node is usually "(BUG) [item described] unimplemented."
A tutorial-node has an object called the tutorial-detail.
 
To decide whether tutorial-tracing: (- tutorial_tracing_flag -).
 
To tutor (T - tutorial-node) with (O - object):
    if tutorial-tracing:
        say "(TUTORIAL) -- [T][if O is not nothing] with [O][end if][if T is closed] (closed)[end if].";
    if T is closed:
        stop;
    let L be the phase-limit of T;
    if L is not zero and L is not tutorial-phase:
        stop;
    now the tutorial-detail of T is O;
    follow the tutorializing rulebook for T.
 
To tutor (T - tutorial-node):
    tutor T with nothing;
 
To say tutor (T - tutorial-node) with (O - object):
    tutor T with O;
 
To say tutor (T - tutorial-node):
    tutor T with nothing;
 
To close (T - tutorial-node):
    if tutorial-tracing:
        say "(TUTORIAL) -- closing [T].";
    now T is closed.
 
Section - The Rulebook and Bare-Array
 
The tutorializing rulebook is a tutorial-node based rulebook.
 
The last tutorializing rule for a tutorial-node (called T):
    instead queue T.
 
To decide what bare-array is tutorial-bare-array: (- tutorial_barearray -).
Include (-
Array tutorial_barearray table 11;
-).
 
[Phrases used in tutorializing rules.]
To queue (T - tutorial-node):
    if object T is listed in tutorial-bare-array:
        stop;
    add T to tutorial-bare-array.
To unqueue (T - tutorial-node):
    let N be the position of object T in tutorial-bare-array;
    if N < 0:
        stop;
    if N + 1 is the count of tutorial-bare-array:
        remove last from tutorial-bare-array;
        stop;
    change object N of tutorial-bare-array to nothing.
 
Before reading a command (this is the display tutorial nodes rule):
    let T be nothing;
    repeat with ix object T running through tutorial-bare-array:
        if T is nothing:
            continue the loop;
        if tutorial-display is true or T is important:
            say "[parsermsg][description of T][/parsermsg][line break]";
        now T is ever-seen;
        if T is one-shot:
            now T is closed;
    clear tutorial-bare-array.
 
After reading a command (this is the command was not blank and also star-note rule):
    [This is a grab-bag of stuff to do before every command.]
    increment command-count;
    now blank-command-counter is zero;
    [I don't think c_style can be left dirty, but paranoia has struck.]
    clean up c_style;
    if the buffer starts with star:
        say "[parsermsg]Noted.[/parsermsg][line break]";
        reject the player's command;
    if the buffer is punctuation-stripped:
        do nothing;
 
[I6 routines are defined in HL Mech now.]
To decide whether the buffer starts with star: (- BufferStartsWithStar() -).
To decide whether the buffer is punctuation-stripped: (- BufferStripPunctuation() -).
 
 
Chapter - The Nodes
 
 
To begin tutorial phase (N - number):
    if tutorial-tracing:
        say "(TUTORIAL) -- phase is [tutorial-phase], changing to [N].";
    if N >= 2 and tutorial-phase < 2:
        now tutorial-phase is 2;
        now tut-ritual-step is 0;
        now tut-ritual-mistake is "";
        close tut-examine;
    if N >= 3 and tutorial-phase < 3:
        now tutorial-phase is 3;
        close tut-recipe;
        close tut-step-sealing;
    if N >= 99 and tutorial-phase < 99:
        now tutorial-phase is 99;
        now tutorial-display is false;
        [close assorted nodes that may not be otherwise closed]
        close tut-discover-table;
        close tut-took-something;
        close tut-recalling-all;
        close tut-examine-closed-door;
        close tut-fail-exiting;
        close tut-assignment;
        close tut-calipers-clean;
        close tut-calipers-clean-again;
        close tut-hatch-clean;
        close tut-does-not-discharge;
    stop.
 
 
Section - Miscellaneous
 
The blank-command-counter is a number that varies.
 
To invoke tutor-blank-command:
    increment blank-command-counter;
    [Special case; can't be a tutorial-node.]
    if tut-initial is open:
        say "[parsermsg]Type [excmd]LOOK[/excmd][period][/parsermsg][br]";
    else:
        if tutorial-phase is:
            -- 1:
                if blank-command-counter >= 2:
                    say "[parsermsg]If you're not sure what to do, try [excmd]EXAMINE[/excmd] on things[period][/parsermsg][br]";
            -- 2:
                if blank-command-counter >= 2:
                    say "[parsermsg]If you're not sure what to do, try [excmd]RECALL TARNISH RITUAL[/excmd][period][/parsermsg][br]";
            [phase 3 and up, I guess we don't say anything.]
 
To invoke tutor-help-command:
    [Another special case; the player typed "HELP" in the first room.]
    if tutorial-display is false:
        say "[parsermsg]The tutorial may be helpful in guiding you through the first room. To turn it on, type [excmd]TUTORIAL[/excmd][period][/parsermsg][br]";
    else if tut-initial is open:
        say "[parsermsg]Type [excmd]LOOK[/excmd][period][/parsermsg][br]";
    else:
        if tutorial-phase is:
            -- 1:
                say "[parsermsg]If you're not sure what to do, try [excmd]EXAMINE[/excmd] on things[period][/parsermsg][br]";
            -- 2:
                say "[parsermsg]If you're not sure what to do, try [excmd]RECALL TARNISH RITUAL[/excmd][period][/parsermsg][br]";
            -- 3:
                say "[parsermsg]If you're not sure what to do, try making use of the ritual you've learned. It must be good for something beyond the calipers[period][/parsermsg][br]";
            -- otherwise:
                say "[parsermsg](BUG) Tutor-help-command called in phase [tutorial-phase][period][/parsermsg][br]";
 
 
Section - Phase 1
 
Tut-initial is a tutorial-node.
The description is "You play this game by typing commands. To look around right now, type [excmd]LOOK[/excmd] and hit [if iOS-UI]Go[else]Enter[end if]."
 
Instead of doing anything when tut-initial is open (this is the must-look-first tutorial rule):
    if looking:
        close tut-initial;
        continue the action;
    tutor tut-initial-force-look;
    stop the action.
 
Tut-initial-force-look is a tutorial-node.
The description is "We'll get to other commands in a moment. For right now, type [excmd]LOOK[/excmd] or [excmd]LOOK AROUND[/excmd]."
 
Tut-invalid-verb is a tutorial-node.
Rule for tutorializing tut-invalid-verb:
    stop.
 
Tut-vague-invoke is a tutorial-node.
The description is "Type [excmd]RECALL[/excmd] for a list of formulas that you know."
 
Tut-look is a tutorial-node.
The phase-limit is 1. [Also closed on tut-examine.]
The description is "There's quite a bit here! You can examine these things more closely. Try [excmd]EXAMINE BENCH[/excmd]."
 
Tut-examine is a tutorial-node.
Tut-examine has a number called the try-counter.
The description is "[tut-examine-desc]".
 
Rule for tutorializing tut-examine:
    close tut-look;
    let T be the tutorial-detail of tut-examine;
    let C be the try-counter of tut-examine;
    if C is not zero and T is on 2nd-lab-table and T is not sh-rust-remover and tut-suggest-take is open:
        now the tutorial-detail of tut-suggest-take is T;
        queue tut-suggest-take;
        stop;
    if the tut-examine-detail of T is "" and C >= 2:
        stop;
    instead queue tut-examine.
 
To say tut-examine-desc:
    let T be the tutorial-detail of tut-examine;
    let D be the tut-examine-detail of T;
    if D is not "":
        clear the tut-examine-detail of T;
    increment the try-counter of tut-examine;
    if the try-counter of tut-examine is one:
        if D is not "":
            say "[D] ";
        say "The [excmd]EXAMINE[/excmd] command works on nearly anything. Since you'll use it so often, you can abbreviate it. Try [excmd]X MYSELF[/excmd][period]";
        stop;
    else if the try-counter of tut-examine is two:
        if D is not "":
            say "[D] ";
        say "Check out the rest of this room. Remember, you can get a general overview by typing [excmd]LOOK[/excmd] or [excmd]L[/excmd][period]";
    else:
        if D is not "":
            say "[D]";
        else:
            say "Interesting[period]"
 
Before examining in 2nd-Lab (this is the tutor examine tutorial rule):
    if tut-initial is closed:
        [We can reach here in the must-look-first phase! Don't tutorialize at that point.]
        tutor tut-examine with the noun;
    continue the action.
 
[A thing has some text called the tut-examine-detail. The tut-examine-detail of a thing is usually "".]
[Replaced with an I6 (sparse) property to save space...]
Include (-
Property i6prop_tut_examine_detail EMPTY_TEXT_VALUE;
-) after "Template Properties" in "Definitions.i6t".
 
To decide what text is the tut-examine-detail of (O - object):
    (- ({O}.i6prop_tut_examine_detail) -).
To clear the tut-examine-detail of (O - object):
    (- if ({O} provides i6prop_tut_examine_detail) {O}.i6prop_tut_examine_detail = EMPTY_TEXT_VALUE; -).
 
Include (-
with i6prop_tut_examine_detail "You've learned a bit about yourself, at least.",
-) when defining yourself.
Include (-
with i6prop_tut_examine_detail "You'll be using these ritual bounds a lot.",
-) when defining the 2nd-bench.
Include (-
with i6prop_tut_examine_detail "You can't do anything about this fracture blockage right now.",
-) when defining the 2nd-lab-fracture.
 
To decide what text is tut-cap-form of (T - object):
    if T is:
        -- brass-pin: decide on "PIN";
        -- steel-bolt: decide on "BOLT";
        -- rosemary: decide on "ROSEMARY";
        -- sh-rust-remover: decide on "SHEET";
        -- ginger-impet: decide on "GINGER";
        -- peppermint-impet: decide on "MINT";
        -- calipers: decide on "CALIPERS";
        -- otherwise: decide on "SOMETHING".
 
Tut-discover-table is a one-shot tutorial-node.
The description is "This looks promising. You can [excmd]EXAMINE[/excmd] any of the items on the table. Common synonyms should work. For example, you can [excmd]EXAMINE THE SHEET[/excmd] or [excmd]READ INSTRUCTIONS[/excmd]."
[### We *could* get here after the instructions are read. (If "read sheet" is the first command.)]
Rule for tutorializing tut-discover-table:
    unqueue tut-examine; [in case "x table" got us here]
    instead queue tut-discover-table.
 
Tut-read-instructions is an important tutorial-node.
The description is "To list what you've memorized, type [excmd]RECALL[/excmd] or [excmd]REMEMBER[/excmd]."
Rule for tutorializing tut-read-instructions:
    unqueue tut-examine; [in case "x sheet" got us here]
    instead queue tut-read-instructions.
 
Tut-fail-opening-hatch is a one-shot tutorial-node.
The description is "That didn't work, but don't give up on the idea. Maybe you'll find a way to clean the rust off later."
 
Tut-recalling-all is a tutorial-node.
The description is "You can recall more about any of these topics. Try [excmd]RECALL AROMA LECTURE[/excmd]."
 
Tut-recalling-formulae is a one-shot tutorial-node.
The description is "Type [excmd]RECALL WORD[/excmd] to remember more about a specific formula. Type [excmd]SPEAK WORD[/excmd] to say one of them out loud."
 
Tut-saw-lecture is a tutorial-node. [silent]
Rule for tutorializing tut-saw-lecture:
    instead close tut-saw-lecture.
 
Tut-saw-nature is a tutorial-node. [silent]
Rule for tutorializing tut-saw-nature:
    instead close tut-saw-nature.
 
Tut-suggest-take is a tutorial-node.
The phase-limit is 1.
The description is "You can pick things up. Try [excmd]TAKE [tut-cap-form of the tutorial-detail of tut-suggest-take][/excmd]."
 
Tut-took-something is a tutorial-node.
The description is "To see what you're carrying, type [excmd]INVENTORY[/excmd] or just [excmd]I[/excmd]."
Rule for tutorializing tut-took-something:
    [This may be triggered after examine or sheet-read node. Consider this low-priority.]
    if the count of tutorial-bare-array is zero:
        close tut-suggest-take;
        queue tut-took-something;
    stop.
 
Check taking inventory:
    close tut-took-something;
    continue the action.
 
Tut-examine-impet is a one-shot tutorial-node.
The description is "[tut-examine-impet-desc]".
Rule for tutorializing tut-examine-impet:
    unqueue tut-examine;
    unqueue tut-suggest-take;
    instead queue tut-examine-impet.
 
To say tut-examine-impet-desc:
    let T be the tutorial-detail of tut-examine-impet;
    if T is closed:
        say "It's closed, which suggests that you can open it. Try [excmd]OPEN [tut-cap-form of T][/excmd][period]";
    else:
        say "These impets can be opened and closed to influence the aroma of your environment[period]".
 
Tut-open-impet is a one-shot tutorial-node.
The description is "You can [excmd]SMELL[/excmd] or [excmd]INHALE[/excmd] to smell what's floating around the room. You can [excmd]SMELL[/excmd] specific objects as well."
 
Tut-examine-closed-door is a tutorial-node.
The description is "It's closed, which suggests that you can open it. Try [excmd]OPEN [if tutorial-detail of tut-examine-closed-door is 2nd-hatch]HATCH[else]DOOR[end if][/excmd]."
Rule for tutorializing tut-examine-closed-door:
    if tut-fail-opening-hatch is ever-seen or the fake-lab-door is discovered:
        [We've tried opening a closed door already.]
        close tut-examine-closed-door;
        stop;
    unqueue tut-examine;
    instead queue tut-examine-closed-door.
 
Tut-examine-bundle is a tutorial-node.
The description is "For a complete list of what you know, type [excmd]RECALL[/excmd] or [excmd]REMEMBER[/excmd]."
Rule for tutorializing tut-examine-bundle:
    if tut-examine-bundle is ever-seen and tut-recalling-all is ever-seen:
        stop;
    unqueue tut-examine;
    instead queue tut-examine-bundle.
 
Tut-fail-exiting is a tutorial-node.
Tut-fail-exiting has a number called the try-counter.
The try-counter of tut-fail-exiting is 0.
The description is "You seem to be stuck in here for the moment. Maybe you should try the assignment that the Sergeant left for you[if tut-fail-exiting is ever-seen]. Type [excmd]RECALL ASSIGNMENT[/excmd][end if]."
Rule for tutorializing tut-fail-exiting:
    let T be the tutorial-detail of tut-fail-exiting;
    let V be zero;
    if T is:
        -- fake-lab-door: now V is 1;
        -- 2nd-lab-fracture: now V is 2;
        -- 2nd-hatch: now V is 4;
    now V is V bitwise-or the try-counter of tut-fail-exiting;
    now the try-counter of tut-fail-exiting is V;
    unless V is 7 and tut-read-instructions is ever-seen:
        stop;
    begin tutorial phase 2;
    [But this remains open until RECALL ASSIGNMENT is done.]
    instead queue tut-fail-exiting.
 
Section - Phase 2
 
Tut-assignment is a tutorial-node.
The description is "You memorized the brass tarnish ritual as well. Type [excmd]RECALL INSCRIPTION[/excmd] or [excmd]RECALL TARNISH RITUAL[/excmd]."
Rule for tutorializing tut-assignment:
    [Active during phase 2. Closed by tut-recipe.]
    if tutorial-phase is 1:
        stop;
    close tut-fail-exiting;
    instead queue tut-assignment.
 
Check recalling the calipers:
    tutor tut-recall-calipers;
    continue the action.
 
Tut-recall-calipers is a tutorial-node.
The phase-limit is 2.
The description is "The tarnished calipers are not the same as the tarnish cleansing ritual. Type [excmd]RECALL TARNISH INSCRIPTION[/excmd] or [excmd]RECALL TARNISH RITUAL[/excmd]."
 
Tut-recipe is a tutorial-node.
The description is "[tut-recipe-desc]".
Rule for tutorializing tut-recipe:
    [Active during phase 2]
    if tutorial-phase is 1:
        stop;
    close tut-assignment;
    close tut-fail-exiting;
    instead queue tut-recipe.
 
To say tut-recipe-desc:
    if tut-step-sealing is not ever-seen:
        say "This shouldn't be hard. ";
    if tut-ritual-step is:
        -- 0:
            say "Take it one step at a time. ";
            if the aroma of the location is no-odor:
                say "Start with the fiery atmosphere[period]";
                if tut-saw-lecture is open:
                    say " [excmd]RECALL AROMA LECTURE[/excmd] for a refresher[period]";
            else if the 2nd-bench is empty:
                say "Put a bit of brass into the workbench bound[period]";
            else:
                say "Say the simple sealing word[period]";
        -- 1:
            say "Now recite the word of essential nature[period]";
            if tut-saw-nature is open:
                say " (This is one of the formulae that you can [excmd]RECALL[/excmd][period])";
        -- 2:
            say "Now add a resinous note to the atmosphere[period]";
            if tut-step-rosemary is not ever-seen:
                say " (The assigment mentioned this; try [excmd]RECALL RESINOUS NOTE[/excmd][period])";
        -- 3:
            say "Finally, recite the Lesser Phlogistical Saturation[period]";
        -- otherwise:
            if rstate is active:
                say "You'll have to start over. [excmd]RECITE UNSEALING[/excmd] to end this ritual[period]";
            else:
                say "You'll have to start over[period]".
 
 
Tut-formula-outside-ritual is a tutorial-node.
The phase-limit is 2.
The description is "A ritual always begins with a sealing word."
 
The tut-ritual-step is a number that varies.
[Follows the player's progress for the purpose of tutorial messages. Generally, N means that steps through N have been done (perhaps badly) and don't need to be re-cued.
- 0: nothing's happened (but aroma or token may be in place, so these steps are complicated)
- 1: say simple sealing
- 2: say nature
- 3: wave rosemary
- 4: say saturation (only if ritual still active, borked)
]
 
The tut-ritual-mistake is a text that varies.
To set tut-ritual-mistake to (T - text):
    if tutorial-tracing:
        say "(TUTORIAL) --";
        if tut-ritual-mistake is not "":
            say " (not)";
        say " setting mistake to '[T]'.";
    if tut-ritual-mistake is "":
        now tut-ritual-mistake is T.
 
Tut-step-impet is a tutorial-node.
The description is "[tut-step-impet-desc]".
The phase-limit is 2.
Rule for tutorializing tut-step-impet:
    if tut-ritual-step is 0:
        queue tut-step-impet;
    stop.
 
To say tut-step-impet-desc:
    let T be the tutorial-detail of tut-step-impet;
    if T is:
        -- ginger-impet: say "Okay, that's fiery. ";
        -- peppermint-impet: say "That's more of an icy aroma. ";
        -- otherwise: say "Okay. ";
    if the 2nd-bench is empty:
        say "Now put a bit of brass into the workbench bound[period]";
    else:
        say "Now say the simple sealing word[period]".
 
Tut-step-insert is a tutorial-node.
The description is "[tut-step-insert-desc]".
The phase-limit is 2.
Rule for tutorializing tut-step-insert:
    if tut-ritual-step is 0:
        queue tut-step-insert;
    if rstate is active:
        set tut-ritual-mistake to "You put something into the bound after the ritual started; that disturbed the energies.";
    stop.
 
To say tut-step-insert-desc:
    let T be the tutorial-detail of tut-step-insert;
    if T is pin-or-bolt:
        say "Good. ";
    else:
        say "Okay. ";
    if the aroma of the location is no-odor:
        say "Now create a fiery atmosphere[period]";
        if tut-saw-lecture is open:
            say " [excmd]RECALL AROMA LECTURE[/excmd] for a refresher[period]";
    else:
        say "Now say the simple sealing word[period]".
 
Tut-step-remove is a tutorial-node. [silent]
The phase-limit is 2.
Rule for tutorializing tut-step-remove:
    if rstate is active:
        set tut-ritual-mistake to "You removed something from the bound after the ritual started; that disturbed the energies.";
    stop.
 
Tut-step-sealing is a tutorial-node.
The description is "[tut-step-sealing-desc]".
Rule for tutorializing tut-step-sealing:
    [This can launch phase 2]
    if tutorial-phase < 2 and tut-read-instructions is ever-seen and rstate is active and the rstate-solo is pin-or-bolt:
        begin tutorial phase 2;
    if tutorial-phase is not 2:
        stop;
    [Now the standard step code]
    if tut-ritual-step is 0:
        now tut-ritual-step is 1;
        queue tut-step-sealing;
        [mistakes...]
        let aroma be the aroma of the location;
        if aroma is:
            -- no-odor: set tut-ritual-mistake to "You didn't open the proper aroma impet before the ritual.";
            -- peppermint: set tut-ritual-mistake to "You used the wrong aroma for the the room, when the ritual started.";
            -- many-odor: set tut-ritual-mistake to "You had too many aroma impets open at the beginning; the mixed aroma wasn't right.";
        if the env of rstate is not fire-based:
            set tut-ritual-mistake to "The elemental attributes of the environment were wrong.";
        let N be the number of things in 2nd-bench;
        if N is zero:
            set tut-ritual-mistake to "You didn't put a token into the bound before you started the ritual.";
        else if N > 1:
            set tut-ritual-mistake to "You put more than one thing into the bound when you started the ritual.";
        else:
            let T be the first thing held by 2nd-bench;
            if T is the calipers:
                set tut-ritual-mistake to "You shouldn't have put the calipers into the bound; you were supposed to use some other bit of brass.";
            else if T is not pin-or-bolt:
                set tut-ritual-mistake to "You put the wrong item into the bound when you started the ritual.";
    stop.
 
To say tut-step-sealing-desc:
    say "The glowing arc indicates that the ritual has begun. ";
    say "Now recite the word of essential nature[period]";
    if tut-saw-nature is open:
        say " (This is one of the formulae that you can [excmd]RECALL[/excmd][period])".
 
Tut-step-unseal is a tutorial-node.
The description is "You can now start the ritual from the beginning."
The phase-limit is 2.
Rule for tutorializing tut-step-unseal:
    now tut-ritual-step is 0;
    now tut-ritual-mistake is "";
    queue tut-step-unseal;
    stop.
 
Tut-step-binding is a tutorial-node. [silent]
The phase-limit is 2.
Rule for tutorializing tut-step-binding:
    if rstate is active:
        set tut-ritual-mistake to "You invoked the word of binding, which is not part of this ritual.";
    stop.
 
Tut-step-nature is a tutorial-node.
The description is "[tut-step-nature-desc]".
The phase-limit is 2.
Rule for tutorializing tut-step-nature:
    if tut-ritual-step <= 2:
        now tut-ritual-step is 2;
        queue tut-step-nature;
    if rstate bestates RSFailed:
        set tut-ritual-mistake to "You invoked the word of essential nature at the wrong time.";
    stop.
 
To say tut-step-nature-desc:
    say "Good. ";
    say "Now add a resinous note to the atmosphere[period]";
    if tut-step-rosemary is not ever-seen:
        say " (The assigment mentioned this; try [excmd]RECALL RESINOUS NOTE[/excmd][period])".
 
Tut-step-rosemary is a tutorial-node.
The description is "[tut-step-rosemary-desc]".
The phase-limit is 2.
Rule for tutorializing tut-step-rosemary:
    if rstate is not active:
        stop;
    if tut-ritual-step <= 3:
        now tut-ritual-step is 3;
        queue tut-step-rosemary;
    if rstate bestates RSFailed:
        set tut-ritual-mistake to "You waved the rosemary at the wrong time.";
    stop.
 
To say tut-step-rosemary-desc:
    say "Refreshing! ";
    say "Finally, recite the Lesser Phlogistical Saturation[period]".
 
Tut-step-saturation is a tutorial-node.
The description is "[tut-step-saturation-desc]".
The phase-limit is 2.
Tut-step-saturation has a text called the short-description.
Rule for tutorializing tut-step-saturation:
    [This is a failure state. The ritual may or may not be still active. (Inactive if, e.g., ginger closed before end.)]
    if tut-ritual-step <= 4:
        now tut-ritual-step is 4;
        now the short-description of tut-step-saturation is tut-ritual-mistake;
        queue tut-step-saturation;
    if rstate is active:
        let T be the rstate-solo;
        if T is not pin-or-bolt:
            [shouldn't get here, really]
            set tut-ritual-mistake to "You moved things into or out of the bound during the ritual.";
    let aroma be the aroma of the location;
    if aroma is not ginger:
        set tut-ritual-mistake to "You changed the atmosphere's aroma during the ritual.";
    if rstate is active and the ritual environment of the location is not fire-based:
        set tut-ritual-mistake to "The elemental attributes of the environment were somehow disturbed.";
    now the short-description of tut-step-saturation is tut-ritual-mistake;
    if rstate is not active:
        [Auto-reset.]
        now tut-ritual-step is 0;
        now tut-ritual-mistake is "";
    stop.
 
To say tut-step-saturation-desc:
    say "That didn't seem to work. ";
    let X be the short-description of tut-step-saturation;
    if X is "":
        now X is "You must have made a mistake[period]";
    say X;
    say "[/parsermsg][br][parsermsg]"; [totally hacky]
    if rstate is active:
        say "You'll have to start over. Speak the unsealing mantra to end this ritual[period]";
    else:
        say "You'll have to start over[period]".
 
Tut-step-success is a tutorial-node.
The description is "[tut-step-success-desc]".
Tut-step-success has a number called the try-counter.
The try-counter of tut-step-success is 0.
Rule for tutorializing tut-step-success:
    [Open in phase 2 and 3]
    if tutorial-phase < 1:
        stop;
    if tutorial-phase is 2:
        begin tutorial phase 3;
    if tutorial-phase > 3:
        stop;
    instead queue tut-step-success.
 
To say tut-step-success-desc:
    let T be the tutorial-detail of tut-step-success;
    if T is brass-pin:
        say "You have completed the ritual! The brass pin will now untarnish the next brass item you touch it to[period]";
        if the calipers are dirty:
            say " Try [excmd]PUT PIN ON CALIPERS[/excmd] or [excmd]TOUCH CALIPERS WITH PIN[/excmd][period]";
    else:
        increment the try-counter of tut-step-success;
        say "You have completed the ritual[exclam-mark]";
        if the try-counter of tut-step-success is 1:
            say " In fact, you've invented a variation of it. [excmd]RECALL[/excmd] will now list the new ritual, and you can [excmd]PERFORM[/excmd] it whenever you want[period]";
            if the 2nd-hatch is dirty:
                say "[/parsermsg][br][parsermsg]"; [totally hacky]
                say "Now see what the steel bolt can be used for[period]";
        else:
            if the 2nd-hatch is dirty:
                say " Now see what the steel bolt can be used for[period]".
 
Tut-calipers-clean is a tutorial-node. [Implicitly one-shot]
The description is "Now that you have practiced the ritual, you can repeat it easily. Try [excmd]PERFORM TARNISH CLEANSING[/excmd]."
 
Tut-calipers-clean-again is a tutorial-node.
The description is "You've demonstrated that you can un-tarnish brass. Perhaps this can lead you to a way out of here."
 
Tut-hatch-clean is a tutorial-node. [Implicitly one-shot]
The description is "Excellent. You can open the hatch now."
 
Tut-does-not-discharge is a tutorial-node.
[Called with pin-or-bolt with basic saturation; the detail is the *target*. Take for granted that the token did not match the target.]
The description is "[tut-does-not-discharge-desc]".
 
To say tut-does-not-discharge-desc:
    let T be the tutorial-detail of tut-does-not-discharge;
    if T is:
        -- 2nd-hatch:
            say "The service hatch isn't made of brass, so the brass-tarnish remover doesn't affect it[period]";
        -- calipers:
            say "You substituted the steel bolt for the brass pin in the tarnish-remover ritual. The bolt won't affect the calipers[period]";
        -- steel-bolt:
            say "The bolt isn't made of brass, so the brass-tarnish remover doesn't affect it[period]";
        -- brass-pin:
            say "The pin isn't made of steel, so the bolt doesn't affect it[period]";
        -- otherwise:
            say "[The T] isn't metallic, so the ritual won't affect it[period]"
 
Tut-complete is a one-shot important tutorial-node.
The description is "You've completed a ritual and escaped the lab. The tutorial is over! You can explore on your own from here..."
Rule for tutorializing tut-complete:
    let oldflag be tutorial-display;
    begin tutorial phase 99;
    if oldflag is false:
        stop;
    instead queue tut-complete.
 
Section - Rest of Game
 
Tut-recall-paper-bundle is an important tutorial-node.
The description is "Type [excmd]RECALL[/excmd] to list the formulas and recipes you've learned."
[RECALL BUNDLE is never useful, so we always nudge the player about this.]
 
Tut-take-void-stairs is an important one-shot tutorial-node.
The description is "If you want to go down the stairs, just type [excmd]DOWN[/excmd]."
 
Tut-open-combo-lock is an important one-shot tutorial-node.
The description is "Try [excmd]SET DIAL TO VENUS[/excmd]."
 
Tut-just-open-it is an important tutorial-node.
The description is "You can just [excmd]OPEN[/excmd] it; you know how."
 
[### if putting bolt/pin in arc, reset count positive, never auto-opened the hatch -- explain about that.]
 
[We could nudge about the void when entering (or maybe leaving) the mech-lab, if the player avoids the void entirely. But probably not worth it.]
 
Tut-recalling-query is an important one-shot tutorial-node.
[This occurs mid-game, when you've learned a lot of topics.]
The description is "You can just type [excmd]FORMULAS[/excmd], [excmd]RITUALS[/excmd], [excmd]FACTS[/excmd], [excmd]PLACES[/excmd], [excmd]OBJECTS[/excmd], or [excmd]DOORS[/excmd] to see these lists."
 
Tut-monocle-action is an important one-shot tutorial-node.
The description is "Try [excmd]LOOK AT SOMETHING THROUGH [if the tutorial-detail of tut-monocle-action is oculus]OCULUS[else]LENS[end if][/excmd]".
 
HL Tutorial ends here.