Skip to content

API reference / @jsprismarine/prismarine / scripting/events/worldEvents

scripting/events/worldEvents ​

Interfaces ​

ScriptWorldEvents ​

Defined in: packages/prismarine/src/scripting/events/worldEvents.ts:43

What a level's scripts hear of the world events WorldEventSource describes.

Methods ​

events() ​

events(listener): () => void

Defined in: packages/prismarine/src/scripting/events/worldEvents.ts:45

Parameters ​
listener ​

(event) => void

Returns ​

() => void

guard() ​

guard(guard): () => void

Defined in: packages/prismarine/src/scripting/events/worldEvents.ts:44

Parameters ​
guard ​

ScriptGameEventGuard

Returns ​

() => void

poll() ​

poll(): void

Defined in: packages/prismarine/src/scripting/events/worldEvents.ts:47

Sends the changes of the state the sources compare, before the script flush takes the events.

Returns ​

void


WorldEventSource ​

Defined in: packages/prismarine/src/scripting/events/worldEvents.ts:24

One game system's world events.

Methods ​

events()? ​

optional events(listener): () => void

Defined in: packages/prismarine/src/scripting/events/worldEvents.ts:34

Calls listener with each of this system's after-events, once the world has kept the change.

Parameters ​
listener ​

(event) => void

Returns ​

A function that stops it.

() => void

guard()? ​

optional guard(guard): () => void

Defined in: packages/prismarine/src/scripting/events/worldEvents.ts:29

Adds a guard to the actions this system's before-events are about.

Parameters ​
guard ​

ScriptGameEventGuard

Returns ​

A function that removes it.

() => void

poll()? ​

optional poll(): void

Defined in: packages/prismarine/src/scripting/events/worldEvents.ts:39

Compares the state this system's events are about with what the last call saw, and sends the listener an after-event for each change, once a tick before the script flush.

Returns ​

void

Functions ​

levelWorldEvents() ​

levelWorldEvents(server, level): ScriptWorldEvents

Defined in: packages/prismarine/src/scripting/events/worldEvents.ts:62

The world events of one level's scripts.

Parameters ​

server ​

Server

The server whose events carry the game systems' changes.

level ​

Level

The level whose worlds the scripts see.

Returns ​

ScriptWorldEvents