More actions
m TheKillerBunny moved page User:TheKillerBunny/Events to Events |
mNo edit summary |
||
(8 intermediate revisions by 2 users not shown) | |||
Line 14: | Line 14: | ||
</syntaxHighlight> | </syntaxHighlight> | ||
Note that not everyone needs to count ticks | Note that not everyone needs to count ticks | ||
== Methods == | |||
{| class="wikitable" | |||
|- | |||
! Method | |||
! Description | |||
|- | |||
| [[#getEvents|getEvents]] | |||
| Returns a table of every event | |||
|} | |||
== Fields == | == Fields == | ||
Line 21: | Line 31: | ||
! Description | ! Description | ||
|- | |- | ||
| ENTITY_INIT | | [[Events/ENTITY_INIT|ENTITY_INIT]] | ||
| Runs when the player is loaded | | Runs when the player is loaded | ||
|- | |- | ||
| TICK | | [[Events/TICK|TICK]] | ||
| Runs every tick the player is rendered | | Runs every tick the player is rendered | ||
|- | |- | ||
| WORLD_TICK | | [[Events/WORLD_TICK|WORLD_TICK]] | ||
| Runs every tick the world is rendered | | Runs every tick the world is rendered | ||
|- | |- | ||
| RENDER | | [[Events/RENDER|RENDER]] | ||
| Runs every frame the player is rendered | | Runs every frame the player is rendered | ||
|- | |- | ||
| POST_RENDER | | [[Events/POST_RENDER|POST_RENDER]] | ||
| Runs every frame AFTER the player is rendered | | Runs every frame AFTER the player is rendered | ||
|- | |- | ||
| WORLD_RENDER | | [[Events/WORLD_RENDER|WORLD_RENDER]] | ||
| Runs every frame the world is rendered | | Runs every frame the world is rendered | ||
|- | |- | ||
| POST_WORLD_RENDER | | [[Events/POST_WORLD_RENDER|POST_WORLD_RENDER]] | ||
| Runs every frame AFTER the world is rendered | | Runs every frame AFTER the world is rendered | ||
|- | |- | ||
| SKULL_RENDER | | [[Events/SKULL_RENDER|SKULL_RENDER]] | ||
| Runs every frame for every skull when the skull is rendered. | | Runs every frame for every skull when the skull is rendered. | ||
|- | |- | ||
| ARROW_RENDER | | [[Events/ARROW_RENDER|ARROW_RENDER]] | ||
| Runs every frame for every arrow when rendered. | | Runs every frame for every arrow when rendered. | ||
|- | |- | ||
| TRIDENT_RENDER | | [[Events/TRIDENT_RENDER|TRIDENT_RENDER]] | ||
| Runs every frame for every trident when rendered. | | Runs every frame for every trident when rendered. | ||
|- | |- | ||
| ITEM_RENDER | | [[Events/ITEM_RENDER|ITEM_RENDER]] | ||
| Runs every frame for every item when rendered. | | Runs every frame for every item when rendered. | ||
|- | |- | ||
| CHAT_SEND_MESSAGE | | [[Events/CHAT_SEND_MESSAGE|CHAT_SEND_MESSAGE]] | ||
| Runs every time the player sends something in chat, including commands. Allows for changing the message | | Runs every time the player sends something in chat, including commands. Allows for changing the message | ||
|- | |- | ||
| CHAT_RECEIVE_MESSAGE | | [[Events/CHAT_RECEIVE_MESSAGE|CHAT_RECEIVE_MESSAGE]] | ||
| Runs every time the player receives something in chat. Allows for changing the message | | Runs every time the player receives something in chat. Allows for changing the message | ||
|- | |- | ||
| MOUSE_SCROLL | | [[Events/MOUSE_SCROLL|MOUSE_SCROLL]] | ||
| Runs every time the mouse is scrolled. Allows for cancelling the vanilla function | | Runs every time the mouse is scrolled. Allows for cancelling the vanilla function | ||
|- | |- | ||
| MOUSE_MOVE | | [[Events/MOUSE_MOVE|MOUSE_MOVE]] | ||
| Runs every time the mouse is moved. Allows for cancelling the vanilla function | | Runs every time the mouse is moved. Allows for cancelling the vanilla function | ||
|- | |- | ||
| MOUSE_PRESS | | [[Events/MOUSE_PRESS|MOUSE_PRESS]] | ||
| Runs every time the mouse is clicked. Allows for cancelling the vanilla function | | Runs every time the mouse is clicked. Allows for cancelling the vanilla function | ||
|- | |- | ||
| KEY_PRESS | | [[Events/KEY_PRESS|KEY_PRESS]] | ||
| Runs every time a key is pressed. Allows for cancelling the vanilla function | | Runs every time a key is pressed. Allows for cancelling the vanilla function | ||
|- | |- | ||
| CHAR_TYPED | | [[Events/CHAR_TYPED|CHAR_TYPED]] | ||
| Runs every time a character is typed. | | Runs every time a character is typed. | ||
|- | |- | ||
| USE_ITEM | | [[Events/USE_ITEM|USE_ITEM]] | ||
| Runs every time an item is used by the player. | | Runs every time an item is used by the player. | ||
|- | |- | ||
| ON_PLAY_SOUND | | [[Events/ON_PLAY_SOUND|ON_PLAY_SOUND]] | ||
| Runs every time a sound is played | | Runs every time a sound is played | ||
|- | |- | ||
| RESOURCE_RELOAD | | [[Events/RESOURCE_RELOAD|RESOURCE_RELOAD]] | ||
| Runs every time resources are reloaded | | Runs every time resources are reloaded | ||
|- | |- | ||
| TOTEM | | [[Events/TOTEM|TOTEM]] | ||
| Runs every time a totem of undying is activated | | Runs every time a totem of undying is activated | ||
|- | |- | ||
| DAMAGE | | [[Events/DAMAGE|DAMAGE]] | ||
| Runs whenever the player takes damage | | Runs whenever the player takes damage | ||
|} | |} | ||
== Methods == | |||
==== getEvents ==== | |||
---- | |||
Returns a table of every event | |||
<syntaxHighlight lang="lua"> | |||
-- Example function to clear all events | |||
function clearEvents() | |||
for _, v in pairs(events:getEvents()) do | |||
v:clear() | |||
end | |||
end | |||
</syntaxHighlight> | |||
[[Category:Globals]] | [[Category:Globals]] |
Latest revision as of 21:30, 9 October 2024
Not to be confused with Event.
Events is a global which contains every Event, which are fired when certain things happen. For example, if you want to count ticks, you can use the tick or world tick event.
local tick = 0
-- Register event
function events.TICK()
tick = tick + 1
end
-- or
events.TICK:register(function()
tick = tick + 1
end)
Note that not everyone needs to count ticks
Methods
Method | Description |
---|---|
getEvents | Returns a table of every event |
Fields
Event | Description |
---|---|
ENTITY_INIT | Runs when the player is loaded |
TICK | Runs every tick the player is rendered |
WORLD_TICK | Runs every tick the world is rendered |
RENDER | Runs every frame the player is rendered |
POST_RENDER | Runs every frame AFTER the player is rendered |
WORLD_RENDER | Runs every frame the world is rendered |
POST_WORLD_RENDER | Runs every frame AFTER the world is rendered |
SKULL_RENDER | Runs every frame for every skull when the skull is rendered. |
ARROW_RENDER | Runs every frame for every arrow when rendered. |
TRIDENT_RENDER | Runs every frame for every trident when rendered. |
ITEM_RENDER | Runs every frame for every item when rendered. |
CHAT_SEND_MESSAGE | Runs every time the player sends something in chat, including commands. Allows for changing the message |
CHAT_RECEIVE_MESSAGE | Runs every time the player receives something in chat. Allows for changing the message |
MOUSE_SCROLL | Runs every time the mouse is scrolled. Allows for cancelling the vanilla function |
MOUSE_MOVE | Runs every time the mouse is moved. Allows for cancelling the vanilla function |
MOUSE_PRESS | Runs every time the mouse is clicked. Allows for cancelling the vanilla function |
KEY_PRESS | Runs every time a key is pressed. Allows for cancelling the vanilla function |
CHAR_TYPED | Runs every time a character is typed. |
USE_ITEM | Runs every time an item is used by the player. |
ON_PLAY_SOUND | Runs every time a sound is played |
RESOURCE_RELOAD | Runs every time resources are reloaded |
TOTEM | Runs every time a totem of undying is activated |
DAMAGE | Runs whenever the player takes damage |
Methods
getEvents
Returns a table of every event
-- Example function to clear all events
function clearEvents()
for _, v in pairs(events:getEvents()) do
v:clear()
end
end