Tell the clock what to do
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.
func run(): if IfVariable("game_completed", true): await ShowMessage({"text": "Three knocks again. Someone is behind that wall."}) return await SetVariable({"name": "game_completed", "value": true}) await StartCutscene({"cutsceneId": "new_cutscene"}) 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.
