Order of events reference

The PulpScript docs are a good reference for what events exist but aren't explicit about the exact order events are called.

I've created a pulp project as a playable reference. It implements all of the default events and logs when they are called. Here is a zip of the json to load into pulp: Pulp Event Reference.zip (4.1 KB)

From that, here are some useful orderings in a few situations:

LAUNCHING THE GAME

The first frames on launching the game proceed as follows:

Frame 0

  • game load
  • rooms load by ascending room id
  • player load
  • sprites/items load by asending tile id
  • game start

Frame 1

  • game enter
  • room enter
  • sprites/items enter left to right, top to bottom
  • player enter
  • player draw

Frame 2

  • game loop
  • player draw

Note that there is no game loop event called until frame 2. Frame 2 is the first frame that can handle input.

NO INPUT

If there is no input just these two events will run by default:

  • game loop
  • player draw

If a say, ask or menu is active the game loop event is not called.

ROOM TRANSITIONS

Room transitions are handled across two frames. If the player moves onto an exit, events proceed as follows:

First frame

  • game loop
  • player update
  • game exit
  • room exit
  • sprites/items exit left to right, top to bottom
  • player exit
  • player draw

Second frame

  • game loop
  • game enter
  • room enter
  • sprites/items enter left to right, top to bottom
  • player enter
  • player draw

Note that the player update occurs before the room transition and there is no second update for the player's new position after the room transition.

FIN

If the player moves onto a fin exit, events proceed as follows:

Fin frame

  • game loop
  • player update
  • game finish

Frames while fin text is on screen

  • no events

Frame after dismissing fin text

  • refer to launching the game

Note there are no exit events when a fin is triggered.

EMIT

When an event is emitted, it is handled by sprites/items in the room in the order left to right, top to bottom.


Hopefully this is a useful reference!

7 Likes

Potentially stupid question, but when the player does make an input, I assume those related events happen in the same frame after game loop and player draw? Do you know what order they occur? I would guess player update comes first, followed by any other appropriate event triggered like confirm or collect.

Not a stupid question at all! These are some standard input triggered scenarios:

INTERACT

i.e. attempt to move into a sprite (with autoact on)

  • game loop
  • player update
  • sprite interact
  • player draw

COLLECT

i.e. move onto an item

  • game loop
  • player update
  • item collect
  • player draw

BUMP

i.e. attempt to move into a solid world tile

  • game loop
  • player update
  • player bump
  • player draw

CONFIRM

i.e. press A

  • game loop
  • player confirm
  • player draw

CANCEL

i.e. press B

  • game loop
  • player cancel
  • player draw

Game loop is always first, player draw is always last, player update is always called before any other events triggered by the player moving.

1 Like

Thanks for putting this together, it's a great resource! If anyone from Panic is reading, this information might make a nice appendix to the PulpScript doc.

I didn't intuitively grok that player draw would come last after an interaction, but it makes the most sense of you think about it.

1 Like