Alpha: this compiler is under active development and updates will break your projects. Not recommended for real use yet.
Skip to content

twine / ModuleScope

Interface: ModuleScope โ€‹

Defined in: twine/src/core/module.interface.ts:13

What a module knows about itself in DatapackModule.register.

Functions the module creates itself don't get its dimension automatically. A block check in the wrong dimension silently never matches, so create them with fn.

Properties โ€‹

dimension? โ€‹

readonly optional dimension?: Dimension

Defined in: twine/src/core/module.interface.ts:18

This module's dimension: its own, the nearest ancestor's, or undefined.


name โ€‹

readonly name: string

Defined in: twine/src/core/module.interface.ts:15

This module's name from its ModuleMetadata.

Methods โ€‹

fn() โ€‹

fn(name, body, opts?): FunctionRef

Defined in: twine/src/core/module.interface.ts:26

Creates a function in this module's group whose body runs in dimension, or in opts.dimension when given. Private unless opts.public.

Use it for functions called from outside the tick tree: admin commands, schedules, rewards.

Parameters โ€‹

name โ€‹

string

body โ€‹

(ctx) => void

opts? โ€‹
dimension? โ€‹

Dimension

public? โ€‹

boolean

Returns โ€‹

FunctionRef


whenOff() โ€‹

whenOff(name, body): FunctionRef

Defined in: twine/src/core/module.interface.ts:36

Creates a private function that runs body only while this module, or a module above it, is switched off in game. For things made outside the tick while off, e.g. freezing a new mob.

Parameters โ€‹

name โ€‹

string

body โ€‹

(ctx) => void

Returns โ€‹

FunctionRef

Released under the MIT License ยท Credits
These docs were written with AI; the layout and every page have been reviewed by a human.