Decide when the panel can open
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.
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.")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
