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.

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

load Event

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


unload Event

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


command Event

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


newchat Event

Called when the game client has begun to add a new line of text to the chat box.

ashita.register_event('newchat', function(mode, chat)
    print('New Chat event fired!');
end);

Parameters

Returns


incoming_packet Event

Called when the client is receiving an incoming packet.

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

Parameters

Returns


outgoing_packet Event

Called when the client is sending an outgoing packet.

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

Parameters

Returns


prerender Event

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


render Event

Called when the client has finished its rendering and other tools can now render.

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

Parameters

Returns


timer_pulse Event

Called when the client is rendering its scene.

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

Parameters

Returns