EventsAPI: Difference between revisions

From FiguraMC
No edit summary
No edit summary
Line 21: Line 21:
! Description
! Description
|-
|-
| getEvents
| [[getEvents|/getEvents]]
| Returns a table of every event
| Returns a table of every event
|}
|}
Line 31: Line 31:
! Description
! Description
|-
|-
| ENTITY_INIT
| [[ENTITY_INIT|/ENTITY_INIT]]
| Runs when the player is loaded
| Runs when the player is loaded
|-
|-
| TICK
| [[TICK|/TICK]]
| Runs every tick the player is rendered
| Runs every tick the player is rendered
|-
|-
| WORLD_TICK
| [[WORLD_TICK|/WORLD_TICK]]
| Runs every tick the world is rendered
| Runs every tick the world is rendered
|-
|-
| RENDER
| [[RENDER|/RENDER]]
| Runs every frame the player is rendered
| Runs every frame the player is rendered
|-
|-
| POST_RENDER
| [[POST_RENDER|/POST_RENDER]]
| Runs every frame AFTER the player is rendered
| Runs every frame AFTER the player is rendered
|-
|-
| WORLD_RENDER
| [[WORLD_RENDER|/WORLD_RENDER]]
| Runs every frame the world is rendered
| Runs every frame the world is rendered
|-
|-
| POST_WORLD_RENDER
| [[POST_WORLD_RENDER|/POST_WORLD_RENDER]]
| Runs every frame AFTER the world is rendered
| Runs every frame AFTER the world is rendered
|-
|-
| SKULL_RENDER
| [[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
| [[ARROW_RENDER|/ARROW_RENDER]]
| Runs every frame for every arrow when rendered.  
| Runs every frame for every arrow when rendered.  
|-
|-
| TRIDENT_RENDER
| [[TRIDENT_RENDER|/TRIDENT_RENDER]]
| Runs every frame for every trident when rendered.  
| Runs every frame for every trident when rendered.  
|-
|-
| ITEM_RENDER
| [[ITEM_RENDER|/ITEM_RENDER]]
| Runs every frame for every item when rendered.  
| Runs every frame for every item when rendered.  
|-
|-
| CHAT_SEND_MESSAGE
| [[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
| [[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
| [[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
| [[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
| [[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
| [[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
| [[CHAR_TYPED|/CHAR_TYPED]]
| Runs every time a character is typed.
| Runs every time a character is typed.
|-
|-
| USE_ITEM
| [[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
| [[ON_PLAY_SOUND|/ON_PLAY_SOUND]]
| Runs every time a sound is played
| Runs every time a sound is played
|-
|-
| RESOURCE_RELOAD
| [[RESOURCE_RELOAD|/RESOURCE_RELOAD]]
| Runs every time resources are reloaded
| Runs every time resources are reloaded
|-
|-
| TOTEM
| [[TOTEM|/TOTEM]]
| Runs every time a totem of undying is activated
| Runs every time a totem of undying is activated
|-
|-
| DAMAGE
| [[DAMAGE|/DAMAGE]]
| Runs whenever the player takes damage
| Runs whenever the player takes damage
|}
|}


[[Category:Globals]]
[[Category:Globals]]

Revision as of 15:12, 27 September 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