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

Decide when the panel can open

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

Most of the night shift uses designer actions. The sorter needs one short script because all three buttons follow the same rule. You’ll enter it in two pieces.

1 In Adventure Database › Scripts, add a regular GDScript named Sorter logic, ID sorter_logic. Leave Keep global instance alive off. In its source editor replace the starter text with this block. Add the code on the next page underneath it before validating. Each indent is four spaces.

Code example
func run(_context = {}):
    if ActivePlayer() != "player":
        await Runtime.show_message("Bea has the yard run. I'll take the radio.", 2)
        return
    if IfVariable("pickup_done"):
        await Runtime.show_message("Load away. Gus can lock up.", 2)
        return
    if not IfVariable("plate_fitted"):
        await Runtime.show_message("A flat claim plate fits that slot.", 2)
        return
    if not IfVariable("dispatch_ok"):
        await Runtime.show_message("Gus needs to badge in at the Lobby radio.", 2)
        return
    Runtime.variables["sort_step"] = 0
    await ShowGUI({"guiId": "sort_board"})
    readout("Choose the first bin.")
Code example
func readout(words):
    SetGUIElementProperty("sort_board", "sort_status", "text", words)

2 Read run from the top. If Gus tries the machine, he tells you whose job it is. If the load has already gone, Bea gets the closing line. Otherwise the plate and the radio both have to be ready before the board opens. The word return stops that attempt right after its message.

GDScript Designer • type in the source pane below the toolbar. Validate and Apply Changes are on that toolbar.

Why reset sort_step here? Bea can back out and ask Gus for the route again. Opening the board starts a fresh three-button attempt. The fitted plate and Gus’s clearance stay exactly where the player left them.

PCA 3D Adventure Studio / 13

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