Skip to reading
First Light, Part 2: Three Knocks

Tell the clock what to do

Edition 0.86.3.4

Part 2 of the First Light course. Import Kit and Pip’s models, assign idle and walk clips, add a one-time clock response, check player saves and run a compiled desktop build.

Download PDFView illustrations

05 / THE ENDING

One short script handles both visits. The first visit plays First Chime and gives Pip a new story beat. A later visit gives one line about the knocks.

1. Create the script. Under Adventure Database, choose Add › GDScript and open the new record. Set Script ID to wind_clock and Name to Wind the Clock. Leave the event boxes clear. The key will call this script when it touches the clock.

2. Enter these seven lines. Click inside the large code area, select all the starter text inside that area, and replace it with the block below. The spaces at the beginnings of lines matter. If you type it yourself, indent the body of run by four spaces and the two lines inside the if by eight.

Code example
func run():
Code example
    if IfVariable("game_completed", true):
Code example
        await ShowMessage({"text": "Three knocks again. Someone is behind that wall."})
Code example
        return
Code example
    await SetVariable({"name": "game_completed", "value": true})
Code example
    await StartCutscene({"cutsceneId": "new_cutscene"})
Code example
    await ShowMessage({"text": "From behind the archive wall come three knocks."})

Read it like a conversation. “Have we finished?” If yes, Pip hears the knocks and return ends the script. Otherwise, mark the game completed, play the existing cutscene, then tell the player what Pip hears. await lets each action finish before the next begins.

3. Check it. In the GDScript toolbar click Validate, then Apply Changes and Save Project. In Part 1 the cutscene’s name was First Chime and its ID was new_cutscene. If you gave yours another ID, substitute that ID inside the quotes on the StartCutscene line.

[1] Validate checks the script. [2] Apply Changes keeps it. You’ll trigger it in play by using the winding key.

Page 6 of 9Permalink
Go to page

Continue your 3D adventure

  1. Part 1First Light, Part 1: Your First 3D Adventure
  2. Part 2First Light, Part 2: Three Knocks
  3. Part 3First Light, Part 3: Behind the Wall
  4. Part 4First Light, Part 4: The Message in the Machine
  5. Part 5First Light, Part 5: The Clockmaker’s Secret
  6. Part 6First Light, Part 6: The Final Hour