Module state/lookups/random

Computed variables that return random values each time they are read. These are guaranteed to stay consistent over multiple sessions. They are:

  • random.coinFlip: either true or false
  • random.fraction: value 0-1
  • random.d4: a value 1-4
  • random.d5: a value 1-5
  • random.d6: a value 1-6
  • random.d8: a value 1-8
  • random.d10: a value 1-10
  • random.d12: a value 1-2
  • random.d20: a value 1-20
  • random.d25: a value 1-25
  • random.d50: a value 1-50
  • random.d100: a value 1-100
  • random.d1000: a value 1-1000

This also adds two regular variables: config.random.seed, which is the seed the random number generator (RNG) uses, and config.random.privateState, which ensures that the RNG behaves deterministically across sessions.

When a lookup occurs, this saves private state to config.random.privateState. This does this once per tick, at the end of the execution context. This is for one very important reason:

  • At init time, this prevents state restoration from local storage from being overwritten mid-load

This practice also:

  • Speeds up execution during play, so every time you read from a random lookup, it doesn't cause state to be saved to local storage

Index

Functions

Generated using TypeDoc