Skip to main content

Sendable

Sometimes, a function sends a value from one instance of the game to another. This may be from one player to another in the same game, or to a future episode of the game. For this reason, the value must be a Sendable value - that is, it must have the same meaning in all possible contexts.

For example, a preference can only store Sendable values because they are stored in one episode, and then loaded in future episodes.

A PressIntent sends an input into the game when a button is pressed. Because of rollback netcode, it is possible that the button may be pressed in one timeline, and received in a different timeline. Complex values like Entity IDs cannot be sent because they may not exist or have a different meaning in the receiving timeline. That is why PressIntent can only send Sendable values.

Only the following types are Sendable:

  • null
  • Boolean
  • Number
  • Vector
  • String
  • Color
  • Flags
  • Keycode
  • Symbol. If you are storing a Symbol in a persistent storage (for example, in a preference), it is best to only use public Symbols (e.g. pub symbol WantsFireball, not just symbol WantsFireball). Private symbols must be encoded with their file path to ensure they remain unique from other symbols with the same name but in different files. This means storing private symbols is not robust to renaming or moving your source files.
  • Array - as long as it only contains Sendable values
  • Map - as long as it only contains Sendable values

Note that the following variables are not Sendable:

  • undefined is not a Sendable. It will just be sent as null if it is encountered.
  • Entities are not Sendable. This is because Entities may not exist in the receiving timeline, or may have a different meaning in the receiving timeline.