Table of Contents

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:


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);


Built-In Events

Below, you will find documentation for the built-in events that the Ashita addons library exposes to all addons. Please be aware of the returns and such of each event as incorrect returns can cause log spam of warnings/errors as well as potential client crashes! Be sure to test your addons thoroughly before having others use them!


Event: load

Called when the current addon is being loaded. (Also called when the addon is reloaded.)

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

Parameters

Returns


Event: unload

Called when the current addon is being unloaded. (Also called when the addon is reloaded.)

ashita.register_event('unload', function()
    print('Unload event fired!');
end);

Parameters

Returns


Event: command

Called when a command has been entered in the game.

ashita.register_event('command', function(cmd, nType)
    print('Command event fired!');
    return false;
end);

Parameters

Returns


Event: incoming_packet

Called when the game client is receiving an incoming packet.

ashita.register_event('incoming_packet', function(id, size, packet, packet_modified, blocked)
    print('Incoming packet event fired!');
    return false;
end);

Parameters

Returns


Event: outgoing_packet

Called when the game client is sending an outgoing packet.

ashita.register_event('outgoing_packet', function(id, size, packet, packet_modified, blocked)
    print('Outgoing packet event fired!');
    return false;
end);

Parameters

Returns


Event: incoming_text

Called when the game client is adding text to the chat log.

ashita.register_event('incoming_text', function(mode, message, modifiedmode, modifiedmessage, blocked)
    print('Incoming text event fired!');
    return false;
end);

Parameters

Returns


Event: outgoing_text

Called when the game client is sending text to the server.
(This gets called when a command, chat, etc. is not handled by the client and is being sent to the server.)

ashita.register_event('outgoing_text', function(mode, message, modifiedmode, modifiedmessage, blocked)
    print('Outgoing text event fired!');
    return false;
end);

Parameters

Returns


Event: prerender

Called when the client is about to start rendering. (Called just after D3D8 BeginScene.)

ashita.register_event('prerender', function()
    print('Prerender event fired!');
end);

Parameters

Returns


Event: render

Called when the client has finished its rendering and other tools can now render. (Called during D3D8 EndScene.)

ashita.register_event('render', function()
    print('Render event fired!');
end);

Parameters

Returns


Event: timerpulse

Called when the client is rendering the scene, used for Addons Lua timers library.
(Addons should not register to this event themselves, it is used for the timers library.)

ashita.register_event('timerpulse', function()
    print('Timer pulse event fired!');
end);

Parameters

Returns