"Lock and Key: Variable": Harlowe (v2.0)

This recipe is affected by history changes in the story. Undoing or re-doing back to a passage containing this recipe has the potential to change its saved values.

Summary

"Lock and Key: Variable" demostrates how to create the effect of picking up a key and unlocking a door. In this example, the key is a variable ($key) and is initially set to the value false in the Start passage.

When the link "Pick up the key" is clicked, $key is changed to the value true and the door link changes from its initial response of "Locked Door" to a link to the passage Exit.

Live Example

Download: Live Example

Twee Code

:: StoryTitle
Lock and Key: Variable in Harlowe

:: Start
(set: $key to false)

Rooms:
[[Front Room]]
[[Back Room]]

:: Front Room
(if: $key is true)[
    [[Exit]]
]
(else:)[
    *Locked Door*
]

Rooms:
[[Back Room]]

:: Back Room
(if: $key is false)[
    Items:
    (link: "Pick up key")[(set: $key to true)You have a key.]
]
(else:)[
    There is nothing here.
]

Rooms:
[[Front Room]]

:: Exit
You found the key and went through the door!

Download: Twee Code

results matching ""

    No results matching ""