Wizards of Lua

The Art of Spell Crafting


EventInterceptor - Intercepting Events

An EventInterceptor represents an interceptor of events.

An interceptor can be obtained through Events.intercept() and Events.on(…):call().

In contrast to an EventQueue, an event interceptor is capable of event mutation and event cancellation since it is called ‘in-line’ with the event occurrence.

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

Here is an overview of the EventInterceptor functions:

Function Parameters Results
 stop  nil

Functions

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


stop () -> nil

The ‘stop’ function terminates this interceptor so that the corresponding function is no longer called for new events.

Example

Intercepting the next chat event and stopping immediately once the first one occurs.

local i
i = Events.on('ChatEvent'):call(function(event)
  print(event.player.name, event.message)
  i:stop()
end)