Skip to content

obsi.state

simadude edited this page Jan 26, 2024 · 2 revisions

This is a module for Obsi that is used to manage the state of the game and its scenes.

Functions of obsi.state:

function description
obsi.state.newScene Creates a new obsi.Scene object.
obsi.state.getScene Returns an existing obsi.Scene object by its name, will return nil if the scene with this name doesn't exist.
obsi.state.setScene Sets the field of the private scenes table to a passed scene. Will remove a scene from that field if the passed scene is nil.
obsi.state.everyScene Basically just pairs() iterator.
obsi.state.setGlobal Sets a variable to some value. Doesn't pollute the global environment.
obsi.state.getGlobal Gets a variable under specific name.

Functions

obsi.state.newScene

Creates a new obsi.Scene object.

Declared as:

state.newScene(sceneName: string) -> obsi.Scene

obsi.state.getScene

Returns an existing obsi.Scene object by its name, will return nil if the scene with this name doesn't exist.

Declared as:

state.getScene(sceneName: string) -> obsi.Scene?

obsi.state.setScene

Sets the field of the private scenes table to a passed scene. Will remove a scene from that field if the passed scene is nil.

Declared as:

state.setScene(sceneName: string, scene: obsi.Scene?)

obsi.state.everyScene

Basically just pairs() iterator.

Declared as:

state.everyScene() -> function

obsi.state.setGlobal

Sets a variable to some value. Doesn't pollute the global environment.

Declared as:

state.setGlobal(name: string, val: any)

obsi.state.getGlobal

Gets a variable under specific name.

Declared as:

state.getGlobal(name: string) -> any