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

twine / DatapackModule

Interface: DatapackModule โ€‹

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

A datapack module: a class with optional lifecycle hooks.

Built once if reachable through the root's imports. Unreachable modules emit nothing.

Methods โ€‹

defineFunction()? โ€‹

optional defineFunction(group, name, body): FunctionRef

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

Creates the function name in group for an @On({ own: true }) body. Override to apply your pack's function conventions. Defaults to group.createFunction(name).

Parameters โ€‹

group โ€‹

Datapack

name โ€‹

string

body โ€‹

(ctx) => void

Returns โ€‹

FunctionRef


onActivate()? โ€‹

optional onActivate(ctx): void

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

Runs once when this module's area becomes active, e.g. to summon its entities. Emitted into <name>/activate.

Parameters โ€‹

ctx โ€‹

FunctionContext

Returns โ€‹

void


onDeactivate()? โ€‹

optional onDeactivate(ctx): void

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

Runs once when this module's area becomes inactive, e.g. to clean up. Emitted into <name>/deactivate.

Parameters โ€‹

ctx โ€‹

FunctionContext

Returns โ€‹

void


onDisable()? โ€‹

optional onDisable(ctx): void

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

Runs once when this module is switched off in game (<name>/disable), e.g. to freeze its entities, since shared plugin ticks may still reach them.

Parameters โ€‹

ctx โ€‹

FunctionContext

Returns โ€‹

void


onEnable()? โ€‹

optional onEnable(ctx): void

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

Runs once when this module is switched back on (<name>/enable), to undo onDisable.

Parameters โ€‹

ctx โ€‹

FunctionContext

Returns โ€‹

void


onEnter()? โ€‹

optional onEnter(ctx): void

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

Runs as the player each time they walk into this area (entrances triggers only). Emitted into <name>/enter; <name>/place moves a player in without it.

Parameters โ€‹

ctx โ€‹

FunctionContext

Returns โ€‹

void


onLoad()? โ€‹

optional onLoad(ctx): void

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

Added to the shared load function. Always runs; not gated by area flags.

Parameters โ€‹

ctx โ€‹

FunctionContext

Returns โ€‹

void


onTick()? โ€‹

optional onTick(ctx): void

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

Added to the shared tick, but only runs while every area ancestor is active.

Parameters โ€‹

ctx โ€‹

FunctionContext

Returns โ€‹

void


register()? โ€‹

optional register(dp, scope): void

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

One-off build-time setup: objectives, functions, structures.

dp is this module's group (dp.root.group(name)), so functions it creates go under the module's name.

scope has the module's dimension; see ModuleScope.

Parameters โ€‹

dp โ€‹

Datapack

scope โ€‹

ModuleScope

Returns โ€‹

void

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