A Handy KitAn interactive fiction by Andrew Plotkin (2006) - the Inform 7 source text | |
Home page Contents Previous Next Complete text | Section - Connectable Triggers
The pushbutton is a trigger in the toolcase. Understand "push" or "button" or "box" as the pushbutton. The description is "It's a small [color] box with a button on one side and a plus link on the other[tool status pushbutton]." Instead of pushing or switching on the pushbutton: if the pushbutton is not connected, instead say "The link dot flashes green in confirmation, but as [the pushbutton] isn't linked to anything, that's all."; change the visible effect to zero; activate the partner of the pushbutton, momentarily; if the visible effect is zero, instead say "You press the button, but nothing happens." Instead of switching off the pushbutton, say "That's not something you can switch off." The toggle switch is a trigger in the toolcase. Understand "toggleswitch" or "toggle-switch" or "box" as the toggle. The description is "It's a small [color] box with a two-way toggle switch on one side, and a plus link on the other[tool status toggle]. The switch is [if toggle is off]off[otherwise]on[end if]." The toggle can be either off or on. The toggle is off. Instead of pushing or turning the toggle: if the toggle is on, try switching off the toggle; otherwise try switching on the toggle. Instead of switching on the toggle: if the toggle is on, instead say "The switch is already on."; change the toggle to on; say "You flip the [color] switch on. "; if the toggle is not connected, instead say "The link dot flashes green in confirmation, but as [the toggle] isn't linked to anything, that's all."; change the visible effect to zero; activate the partner of the toggle; if the visible effect is zero, instead say "There is no apparent effect." Instead of switching off the toggle: if the toggle is off, instead say "The switch is already off."; change the toggle to off; say "You flip the [color] switch off. "; if the toggle is not connected, instead say "The link dot flashes blue in confirmation, but as [the toggle] isn't linked to anything, that's all."; change the visible effect to zero; deactivate the partner of the toggle; if the visible effect is zero, instead say "There is no apparent effect." The timer is a trigger in the toolcase. Understand "dials" or "indicator" or "box" as the timer. The description is "It's a small [color] box with with two dials on one side, and a plus link on the other[tool status timer]. The status dot is [if on]green[otherwise]blue[end if]. [timer status]". Instead of reading the timer: say "[timer status]". Check turning when the noun is the timer: instead say "You can set the timer's green dial or its blue dial." Check setting vaguely when the noun is the timer: instead say "You can set the timer's green dial or its blue dial." Check dialing it to when the noun is the timer: instead say "You can set the timer's green dial or its blue dial." [The rule here: you can twiddle dials as you like; you don't get a countdown until you press the dial. If one dial is running, it's in the opposite state, and goes to the dial's state when the dial runs out. If you press the running dial, it stops (and the indicator vanishes.) If you press the non-running dial, it goes on, and you then get alternation. Press the non-running dial again, it shorts to that state of the alternation.] The timer can be either off or on. The timer is off. The timer can be neutral, switching, or alternating. The timer is neutral. The timer has a number called the setting. The setting of the timer is zero. The timer can be skipping this turn. The timer is not skipping this turn. To say timer status: if the on-dial is the same setting as the off-dial, say "Both the green and blue dials are set to [setting of on-dial]; "; otherwise say "The green dial is set to [setting of on-dial] and the blue dial to [setting of off-dial]; "; if the timer is switching, say "the [if on]blue[otherwise]green[end if] dial is lit. The"; if the timer is alternating, say "both dials are lit. The"; if the timer is neutral, say "the"; say " timer's indicator [if setting of timer is zero]is blank[otherwise]reads [setting of timer][end if]." Rule for engaging the timer: now the timer is on; change the visible effect to zero; if the timer is not connected and the timer is visible, instead say "The link dot goes green, but as [the timer] isn't linked to anything, that's all."; if the timer is connected, activate the partner of the timer; if the visible effect is zero and the timer is visible, instead say "The status dot goes green." Rule for disengaging the timer: now the timer is off; change the visible effect to zero; if the timer is not connected and the timer is visible, instead say "The link dot goes blue, but as [the timer] isn't linked to anything, that's all."; if the timer is connected, deactivate the partner of the timer; if the visible effect is zero and the timer is visible, instead say "The status dot goes blue." A dial-instance is a kind of thing. Understand "dial" as a dial-instances. Understand the color property as describing dial-instances. [I had some trouble here until I figured out the trick of using hyphenated terms for source-code names (which the player is unlikely to type), and then "understand" statements to parse player input. I did not, for example, want "dials" to be a valid descriptor of each dial -- the timer handles that.] Rule for printing the name of a dial-instance: say "[color] dial". A dial-instance is always not perfumizable. The on-dial and the off-dial are dial-instances which are part of the timer. A dial-instance has a number called the setting. The setting of a dial-instance is usually 1. A dial-instance has a color. The color of the on-dial is green. The color of the off-dial is blue. The description of a dial-instance is "[The item described] is set to [setting]." To decide which dial-instance is the current dial: if the timer is on, decide on the on-dial; otherwise decide on the off-dial. The timer-oneshot is a oneshot. [A one-time flag for explaining how the dials work.] Before setting vaguely or turning a dial-instance: instead say "The dial can be set from 1 to 20." Check dialing it to when the noun is a dial-instance: if the number understood is less than 1 or the number understood is greater than 20, instead try setting vaguely the noun; change the setting of the noun to the number understood; say "You set [the noun] to [the setting of the noun]"; if first trying the timer-oneshot, say ". (Press the dials to activate them.)"; otherwise say "."; stop. Instead of pushing a dial-instance (called this-dial) when timer is neutral: now the timer is switching; now the timer is skipping this turn; change the setting of the timer to the setting of this-dial; now the timer-oneshot is fired; say "[The this-dial] lights as you press it. The timer's indicator flashes to [setting of this-dial].[conditional paragraph break]"; if this-dial is the current dial begin; if this-dial is the on-dial begin; carry out the disengaging activity with the timer; otherwise; carry out the engaging activity with the timer; end if; end if. Instead of pushing a dial-instance (called this-dial) when timer is switching: if this-dial is the current dial begin; now the timer is alternating; say "[The this-dial] is now lit as well."; otherwise; now the timer is neutral; change the setting of the timer to zero; say "[The this-dial] goes out, and the timer's indicator goes blank."; end if. Instead of pushing a dial-instance (called this-dial) when timer is alternating: now the timer is neutral; change the setting of the timer to zero; say "Both dials go out, and the timer's indicator goes blank." [And the "daemon" procedure:] Every turn when the timer is not neutral: if the timer is skipping this turn begin; now the timer is not skipping this turn; stop; end if; decrease the setting of the timer by 1; if the setting of the timer is greater than zero begin; if the timer is visible, say "The timer changes to [setting of the timer]."; stop; end if; let this-dial be the current dial; if the timer is alternating begin; if the timer is visible, say "The timer's [this-dial] flashes once, and the indicator blinks to [setting of this-dial]. "; change the setting of the timer to the setting of this-dial; otherwise; now the timer is neutral; change the setting of the timer to zero; if the timer is visible, say "The timer reaches zero. "; end if; if the timer is on, carry out the disengaging activity with the timer; otherwise carry out the engaging activity with the timer; The radio module is a trigger in the toolcase. Understand "short" or "antenna" or "box" as the radio module. The description is "It's a small [color] box with a short antenna on one side and a plus link on the other[tool status radio module]." The voice module is a trigger in the toolcase. Understand "short" or "antenna" or "box" as the voice module. The description is "It's a small [color] box with a short antenna on one side and a plus link on the other[tool status voice module]." |