Skip to reading
PCA Script Programming

Events: phrases, shared hooks and payloads

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 PDF page
On this page

Earlier edition reference / Current 0.86.4.0 property paths > p. 329

The following 18 entries map the shared runtime hooks to PCA source headers. IDs in the readable headers are examples: replace lab, welcome_trigger, elias_intro and media IDs with your own. Each handler ends with end.

PCA when handlers are discovered in enabled source records. They are not the same as merely naming a function after a native handler. Exact-name form, when event Name, matches the event name the runtime dispatches.

Event context is supplied by the emitter. Check optional keys and inspect event when debugging. return is only legal inside a function, not directly inside when. Put a handler’s work in a function when you need an early return, or guard it with if.

OnGameStart#

Code example
when game starts
    log(to_json(event))
end

The runtime reaches its game-start hook. It is a game-session event, not a once-per-room event.

Source table from Events: phrases, shared hooks and payloads, page 293
Common context keysUse and limits
sceneId, playerIdInitialize session-level logic here. Do not reset saved puzzle variables on every scene entry. A direct Test Scene can start a test session too; test a normal new game and a loaded game separately.

OnSceneLoaded#

Code example
when room lab loads
    log(to_json(event))
end

A room has been constructed and its local entry actions have run.

Source table from Events: phrases, shared hooks and payloads, page 293
Common context keysUse and limits
sceneId, previousSceneId, playerId, firstVisitFilter sceneId before changing room-specific props. In the normal entry path, firstEnter runs before enter, then this event is emitted. It is not a substitute for the room's first-time event.
Page 293 of 357Permalink
Go to page