Manages callbacks that are connected to when a button is pushed.

Example

buttonPushEvent.ts

import { world, ButtonPushAfterEvent, system } from '@minecraft/server';

world.afterEvents.buttonPush.subscribe((buttonPushEvent: ButtonPushAfterEvent) => {
const eventLoc = buttonPushEvent.block.location;

world.sendMessage(
`Button push event at tick ${system.currentTick} Power:${buttonPushEvent.block.getRedstonePower()}`,
);
});

Hierarchy

Constructors

Methods

Constructors

Methods

  • Parameters

    Returns ((arg) => void)

      • (arg): void
      • Parameters

        Returns void

        Remarks

        Subscribes to the event.

        This function can't be called in read-only mode.

    Remarks

    Subscribes to the event.

    This function can't be called in read-only mode.