c0llage

State

Overview

(see this page for an overview of shared globals)

There is now a global shared state throughout the game that can be accessed in the global object like the following:

window.top.d.State
//or if imported globals.js, simply
d.State

State is a plain js object, and can store whatever you want. However, it’s good practice to define the initial values of things in the state, which can be done in the file global.js.

Currently the initialState is defined as the following:

const initialState = {
  sawMessyServerNarrative: false,
  visitedAlidator: false,
  visitedPrometeus: false,
}

Listening to State Changes

You can also listen to specific state changes if you want to, the way to do it is with the global ListenState(propertyName) function:

For example:

d.State.listen('sawMessyServerNarrative', (value) => {
  console.log('sawMessyServerNarrative changed to ' + value)
})

Clearing the State

For debugging purposes, you can clear the saved state completely by typing window.top.d.State.clear() into the console.

Current State Information

TODO