This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
addons:events [2017/04/21 19:52] atom0s |
addons:events [2017/04/22 00:10] (current) |
||
---|---|---|---|
Line 22: | Line 22: | ||
**Short-hand Method** | **Short-hand Method** | ||
- | <code lua> | + | <sxh lua> |
ashita.register_event('load', function() | ashita.register_event('load', function() | ||
print('Load event fired!'); | print('Load event fired!'); | ||
end); | end); | ||
- | </code> | + | </sxh> |
**Long-hand Method** | **Long-hand Method** | ||
- | <code lua> | + | <sxh lua> |
function loadfunction() | function loadfunction() | ||
print('Load event fired!'); | print('Load event fired!'); | ||
Line 35: | Line 35: | ||
ashita.register_event('load', loadfunction); | ashita.register_event('load', loadfunction); | ||
- | </code> | + | </sxh> |
+ | |||
+ | ---- | ||
+ | |||
+ | ===== 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! | ||
---- | ---- | ||
Line 42: | Line 48: | ||
Called when the current addon is being loaded. (Also called when the addon is reloaded.) | Called when the current addon is being loaded. (Also called when the addon is reloaded.) | ||
- | <code lua> | + | <sxh lua> |
ashita.register_event('load', function() | ashita.register_event('load', function() | ||
print('Load event fired!'); | print('Load event fired!'); | ||
end); | end); | ||
- | </code> | + | </sxh> |
**Parameters** \\ | **Parameters** \\ | ||
Line 59: | Line 65: | ||
Called when the current addon is being unloaded. (Also called when the addon is reloaded.) | Called when the current addon is being unloaded. (Also called when the addon is reloaded.) | ||
- | <code lua> | + | <sxh lua> |
ashita.register_event('unload', function() | ashita.register_event('unload', function() | ||
print('Unload event fired!'); | print('Unload event fired!'); | ||
end); | end); | ||
- | </code> | + | </sxh> |
**Parameters** \\ | **Parameters** \\ | ||
Line 76: | Line 82: | ||
Called when a command has been entered in the game. | Called when a command has been entered in the game. | ||
- | <code lua> | + | <sxh lua> |
ashita.register_event('command', function(cmd, nType) | ashita.register_event('command', function(cmd, nType) | ||
print('Command event fired!'); | print('Command event fired!'); | ||
return false; | return false; | ||
end); | end); | ||
- | </code> | + | </sxh> |
**Parameters** \\ | **Parameters** \\ | ||
Line 95: | Line 101: | ||
Called when the game client is receiving an incoming packet. | Called when the game client is receiving an incoming packet. | ||
- | <code lua> | + | <sxh lua> |
ashita.register_event('incoming_packet', function(id, size, packet, packet_modified, blocked) | ashita.register_event('incoming_packet', function(id, size, packet, packet_modified, blocked) | ||
print('Incoming packet event fired!'); | print('Incoming packet event fired!'); | ||
return false; | return false; | ||
end); | end); | ||
- | </code> | + | </sxh> |
**Parameters** \\ | **Parameters** \\ | ||
Line 119: | Line 125: | ||
Called when the game client is sending an outgoing packet. | Called when the game client is sending an outgoing packet. | ||
- | <code lua> | + | <sxh lua> |
ashita.register_event('outgoing_packet', function(id, size, packet, packet_modified, blocked) | ashita.register_event('outgoing_packet', function(id, size, packet, packet_modified, blocked) | ||
print('Outgoing packet event fired!'); | print('Outgoing packet event fired!'); | ||
return false; | return false; | ||
end); | end); | ||
- | </code> | + | </sxh> |
**Parameters** \\ | **Parameters** \\ | ||
Line 143: | Line 149: | ||
Called when the game client is adding text to the chat log. | Called when the game client is adding text to the chat log. | ||
- | <code lua> | + | <sxh lua> |
ashita.register_event('incoming_text', function(mode, message, modifiedmode, modifiedmessage, blocked) | ashita.register_event('incoming_text', function(mode, message, modifiedmode, modifiedmessage, blocked) | ||
print('Incoming text event fired!'); | print('Incoming text event fired!'); | ||
return false; | return false; | ||
end); | end); | ||
- | </code> | + | </sxh> |
**Parameters** \\ | **Parameters** \\ | ||
Line 172: | Line 178: | ||
//(This gets called when a command, chat, etc. is not handled by the client and is being sent to the server.)// | //(This gets called when a command, chat, etc. is not handled by the client and is being sent to the server.)// | ||
- | <code lua> | + | <sxh lua> |
ashita.register_event('outgoing_text', function(mode, message, modifiedmode, modifiedmessage, blocked) | ashita.register_event('outgoing_text', function(mode, message, modifiedmode, modifiedmessage, blocked) | ||
print('Outgoing text event fired!'); | print('Outgoing text event fired!'); | ||
return false; | return false; | ||
end); | end); | ||
- | </code> | + | </sxh> |
**Parameters** \\ | **Parameters** \\ | ||
Line 200: | Line 206: | ||
Called when the client is about to start rendering. (Called just after D3D8 BeginScene.) | Called when the client is about to start rendering. (Called just after D3D8 BeginScene.) | ||
- | <code lua> | + | <sxh lua> |
ashita.register_event('prerender', function() | ashita.register_event('prerender', function() | ||
print('Prerender event fired!'); | print('Prerender event fired!'); | ||
end); | end); | ||
- | </code> | + | </sxh> |
**Parameters** \\ | **Parameters** \\ | ||
Line 217: | Line 223: | ||
Called when the client has finished its rendering and other tools can now render. (Called during D3D8 EndScene.) | Called when the client has finished its rendering and other tools can now render. (Called during D3D8 EndScene.) | ||
- | <code lua> | + | <sxh lua> |
ashita.register_event('render', function() | ashita.register_event('render', function() | ||
print('Render event fired!'); | print('Render event fired!'); | ||
end); | end); | ||
- | </code> | + | </sxh> |
**Parameters** \\ | **Parameters** \\ | ||
Line 235: | Line 241: | ||
//(Addons should not register to this event themselves, it is used for the timers library.)// | //(Addons should not register to this event themselves, it is used for the timers library.)// | ||
- | <code lua> | + | <sxh lua> |
ashita.register_event('timerpulse', function() | ashita.register_event('timerpulse', function() | ||
print('Timer pulse event fired!'); | print('Timer pulse event fired!'); | ||
end); | end); | ||
- | </code> | + | </sxh> |
**Parameters** \\ | **Parameters** \\ |