Wizards of Lua

The Art of Spell Crafting


Event - The Event Base Class

The Event class represents a notification about something that happend in the world.

The Event class is a subtype of the Object class and inherits all its properties and functions.

Here is an overview of the Event properties:

Property Type read / write
cancelable boolean r
canceled boolean r/w
name string r

Properties

Below you find short descriptions about each of the properties and some examples about how to use them in your spells.


cancelable : boolean

The ‘cancelable’ property can be used to detect dynamically whether this event instance can be canceled.

In general, this is determined by the event class.

For instance, a BlockPlaceEvent is cancelable, but a SwingArmEvent is not.


canceled : boolean

The ‘canceled’ property can be used to define that this event should be canceled.

If cancelable is false, then setting canceled results in an error.

Please note, an event can only be canceled during event interception.

Example

Canceling all chat messages from player ‘mickkay’.

Events.on('ChatEvent'):call(function(event)
  if event.player.name == 'mickkay' then
     event.canceled = true
  end
end)

name : string

The name of this kind of event. Use this name to connect an event queue to the event source for events of this kind.