S08 · Sat, Nov 7, 2026

Build an If/Else Guardian

Predict two branches, fix an inverted condition, and hear both answers at the Cloud Gate.

S08 · 1 / 8

Follow the Sky Lantern signal

The signal leads Nova to the Cloud Gate. Can the Guardian give Nova a clue when the switch is off and a welcome when it is on?

S08 · 2 / 8

Predict both responses

Before running Python, write the response that should go with each input. Read your rule aloud using “If … then … otherwise …”.

guardian_response(False) → __________________
guardian_response(True)  → __________________

S08 · 3 / 8

Run the starter

def guardian_response(is_on):
    if not is_on:
        return "The portal is glowing!"
    else:
        return "The portal is sleeping."
python lessons/sessions/s08/student/starter.py

The starter calls the function with False first. Trace which branch it takes. How does not change that input?

S08 · 4 / 8

Repair the condition

Change the condition to if is_on: and run both cases again. The if block runs for True and the else block runs for False.

The portal is sleeping.
The portal is glowing!

Point to the return line that produced each response.

S08 · 5 / 8

Connect the Guardian to the switch

The Python function models a decision. The Trail reads its own switch state and chooses a response from character/gate-guardian.yaml.

  • object_id: "sky-switch" links the Guardian to the switch in the same package.
  • when_off gives Nova a clue. Keep the Sky Switch in your clue.
  • when_on gives Nova a welcome.

S08 · 6 / 8

Validate and launch Moon Meadow

explore-package validate lessons/sessions/s08/student/explorer-package
valid: cloud-gate 0.1.0
explore-package trail examples/explorer-packages/nova-character lessons/sessions/s08/student/explorer-package --player "nova-character:nova" --mission-id "respond-to-object-state" --name "S08 Build an If/Else Guardian"

Copy the complete launch line. Nova starts near the Guardian. Move toward the talk prompt and press E.

S08 · 7 / 8

Hear the clue, then test it

  1. Talk to the Guardian with the switch OFF. Read the clue and look for Responses 1 / 2.
  2. Walk left to the Sky Switch and press E at the prompt. Look for its yellow glow.
  3. Return to the Guardian and press E. Read the new line and look for Responses 2 / 2.
The Gate Guardian asks Nova to wake the Sky Switch. The HUD shows Responses 1 / 2.

S08 · 8 / 8

Show both branches

M08 completes after you hear both responses. Nova can walk past the Guardian in either state. The Guardian’s dialogue tells the story of the gate opening.

Write down both lines and explain which state selected each one. If you use AI, ask it to compare your predictions with your results after you explain the condition.

Review the Python notes →