User Tools

Site Tools


addons:events

This is an old revision of the document!


Events

One of the main ways that Ashita allows addons to obtain various important data from the hook is through the method of events. Events are callback functions that are fired within an addons Lua state whenever the hook core handles something that warrants an addon to be notified. This can happen for things such as incoming or outgoing packets, chat commands entered by the user, etc.

The following events are currently valid within Ashita's core hook that are exposed to addons:

  • load
  • unload
  • command
  • incoming_packet
  • outgoing_packet
  • incoming_text
  • outgoing_text
  • prerender
  • render
  • timerpulse

Registering To Events

Addon developers can register to an event using one of two methods. The short-hand method, or the long-hand method. In most cases, the short-hand method will be ideal and recommended.

Short-hand Method

ashita.register_event('load', function()
    print('Load event fired!');
end);

Long-hand Method

function loadfunction()
    print('Load event fired!');
end
 
ashita.register_event('load', loadfunction);
addons/events.1492827228.txt.gz · Last modified: 2017/04/21 19:13 by atom0s