Appearance
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()? โ
optionaldefineFunction(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()? โ
optionalonActivate(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()? โ
optionalonDeactivate(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()? โ
optionalonDisable(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()? โ
optionalonEnable(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()? โ
optionalonEnter(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()? โ
optionalonLoad(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()? โ
optionalonTick(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()? โ
optionalregister(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 โ
Returns โ
void