Skip to reading
The Sock Exchange, Part 5: The Midnight Pickup

Check one button press

Edition 0.86.4.2

0.86.4.2 edition with appended native sprite-motion lessons. Earlier chapters, reference counts and screenshots retain their original edition context.

Download PDFView illustrations

TUTORIAL 05 • SCRIPT EDITOR + SCENE DESIGNER

Every chute calls the same function. It supplies one word: sheets, socks or towels. The function checks that word against the next entry on Gus’s list.

1 Leave one blank line after readout on page 13. Type this block in the same script. Start func press_bin at the left margin, lined up with func run. Click Validate, then Apply Changes and save.

Code example
func press_bin(bin_name):
    if ActivePlayer() != "player" or CurrentScene() != "service_yard":
        await HideGUI({"guiId": "sort_board"})
        return
    if IfVariable("pickup_done"):
        return
    var route = ["sheets", "socks", "towels"]
    var step = int(Runtime.variables.get("sort_step", 0))
    if bin_name != route[step]:
        Runtime.variables["sort_step"] = 0
        readout("Wrong chute. Start again at the first bin.")
    else:
        step += 1
        Runtime.variables["sort_step"] = step
        if step == route.size():
            Runtime.variables["pickup_done"] = true
            readout("Load dispatched! Gus can lock up.")
        else:
            readout("Accepted. Choose bin %d of 3." % (step + 1))
    Runtime.state_changed()

2 In Scene Designer › Service Yard › Yard sorter › Verb Actions › Use, choose Run Visual Script, then Sorter logic (sorter_logic). Apply Changes. This plain Use action runs the GDScript on page 13. The two item rules still belong under Inventory Actions.

Scene Designer • the sorter’s plain Use action calls Sorter logic.

Read one turn. At step 0, the expected word is sheets. A correct press adds 1. A wrong press puts the counter back at 0 and leaves a retry message on screen. The third correct press sets pickup_done. Further button presses leave the success message in place.

PCA 3D Adventure Studio / 14

Page 14 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