Skip to reading
The Sock Exchange, Part 6: Closing Time

Reveal one more clue

Edition 0.86.4.1 HF1

0.86.4.1 Hotfix 1 edition. Earlier lessons and screenshots retain their original version context; revised references and supplements describe the newer behavior.

Download PDFView illustrations

SCRIPT DESIGNER / ONE SHORT SCRIPT

The Ask button needs to answer two questions. Which part of the pickup is unfinished? How many hints for that part has the player already seen? One short script handles both.

1. In Adventure Database › Scripts, add a regular GDScript named Next clue, ID shift_hint. Leave Keep global instance alive off. Replace the starter text with the whole block below. Indent each level with four spaces. Click Validate, then Apply Changes, and save.

Code example
func run(_context = {}):
Code example
    if IfVariable("pickup_done"):
Code example
        await ShowMessage({"text": "The last load is out. You can lock up."})
Code example
        return
Code example
    var topic = "washer"
Code example
    if IfVariable("washer_fixed"):
Code example
        topic = "plate"
Code example
        if IfVariable("plate_fitted"):
Code example
            topic = "radio"
Code example
            if IfVariable("dispatch_ok"):
Code example
                topic = "bins"
Code example
    var seen = Runtime.variables.get("hintsUnlocked", {})
Code example
    var count = mini(3, int(seen.get(topic, 0)) + 1)
Code example
    await UnlockHint({"topicId": topic, "answerNumber": count})

Regular GDScript editor. Enter the block in the source pane. Validate checks the script; Apply Changes saves it to this record.

2. Read the four names inside the block. The script starts with the washer. A repaired washer leads to the plate. A fitted plate leads to the radio. A fitted plate plus Gus’s clearance leads to the bins. If the load has left, the player gets a closing line.

3. Open GUI Designer › Night shift notebook. Select Ask for one clue. Set Events › Click to run-visual-script and Click Target to shift_hint. This button action also runs a regular PCA GDScript, just as the sorter did in Part 5. Save.

Why the last three lines matter. The number passed to UnlockHint is the total to show. Asking a second time reveals answer 2 while keeping answer 1. The cap of 3 prevents a fourth click from revealing a different puzzle. PCA saves the counts in hintsUnlocked. There is no extra variable to create.

Page 10 of 19Permalink
Go to page

Continue your 2D adventure

  1. Part 1The Sock Exchange, Part 1: Your First 2D Adventure
  2. Part 2The Sock Exchange, Part 2: The Missing Laundry
  3. Part 3The Sock Exchange, Part 3: The Dryer Conspiracy
  4. Part 4The Sock Exchange, Part 4: Trouble After Closing
  5. Part 5The Sock Exchange, Part 5: The Midnight Pickup
  6. Part 6The Sock Exchange, Part 6: Closing Time