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

twine / On

Function: On() โ€‹

On(detector, opts?): MethodDecorator

Defined in: twine/src/core/events/register.ts:31

Runs the decorated method when detector holds.

ts
@Module({ name: "stage1", area: true, tickEvery: 10 })
export class Stage1Module {
  @On(Detect.in(THE_END, Detect.block(BUTTON_POS, PRESSED)), { own: true })
  waterButton(ctx: FunctionContext) {
    ctx.execute().in(THE_END).run((c) => c.setblock(GAP, Block.AIR));
  }
}

The method runs once at build time and emits commands, like other lifecycle hooks. For bodies on a helper object rather than the module class, use on / every.

Parameters โ€‹

detector โ€‹

Detector

opts? โ€‹

OnOptions = {}

Returns โ€‹

MethodDecorator

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