Search the docs

Find a guide, global, type or member

TypeEmber

Event

What a built-in event's handler receives; see EventName for which fields each event fills. Fields an event does not carry are nil. Only usable while its handlers run: keeping it and using it later raises. To cancel a cancellable event, return false or call e:cancel(). Every handler still runs after one cancels; check cancelled. Returning false from a non-cancellable event is ignored, e:cancel() on one raises. An event that happens while your script is already running (say, one your own teleport causes) is delivered afterwards, too late for cancelling or setters to matter.

Fields

event.name: EventName | string#
event.cancelled: boolean#

true once a handler cancelled it

event.cancellable: boolean#

whether this event can be cancelled

event.player: Player?#

The player the event is about.

event.entity: Entity?#

The entity the event is about (entityDamage, entityDeath).

event.attacker: Player?#

The player who caused the damage or death, when it was a player.

event.targetPlayer: Player?#

The player who was clicked or hit, when the target is a player.

event.target: Entity?#

entityInteract, playerAttack: the clicked entity. At runtime this is currently the platform's numeric entity id, not an Entity handle.

event.x: number?#

Block events: the block. playerMove: the destination. playerRespawn: the respawn point.

event.y: number?#
event.z: number?#
event.fromX: number?#

playerMove: where the player came from

event.fromY: number?#
event.fromZ: number?#
event.block: number?#

a blocks id

event.face: string?#

"up", "down", "north", "south", "east" or "west"

event.hand: string?#

"main_hand" or "off_hand"

event.item: string?#

item key of the stack involved

event.count: number?#

size of that stack

event.amount: number?#

damage about to be dealt, in half-hearts

event.cause: string?#

damage type key, e.g. "minecraft:fall"

event.drops: boolean?#

whether the death drops loot

Methods

event:cancel()#

Cancels the event. Raises if it is not cancellable.

event:setAmount(amount: number)#

playerDamage, entityDamage: changes the damage dealt. Raises on other events.

event:setDestination(x: number, y: number, z: number)#

playerMove: sends the player here instead. Raises on other events.

event:setPosition(x: number, y: number, z: number)#

playerRespawn: respawns the player here. Raises on other events.

event:setDrops(drops: boolean)#

playerDeath, entityDeath: turns loot drops on or off. Raises on other events.