Event (type): Difference between revisions

From FiguraMC
Created page with "The event type is used for events such as `events TICK`. To create an event function, use one of the following. <syntaxHighlight lang="lua"> function events[EVENT]() end -- OR events[EVENT]:register(function() end) -- optionally as a name argument to allow removal </syntaxHighlight> {| class="wikitable" |- ! | Method ! | Description |- | remove | Takes in a [https://lua.org/manual/5.1/manual.html#5.4 string] with the name of the event, and removes it, stopping it from..."
 
No edit summary
Line 1: Line 1:
The event type is used for events such as `events
The event type is used for events such as <code>events.TICK</code>. To create an event function, use one of the following.
TICK`. To create an event function, use one of the following.


<syntaxHighlight lang="lua">
<syntaxHighlight lang="lua">
Line 10: Line 9:
</syntaxHighlight>
</syntaxHighlight>


== Methods ==
{| class="wikitable"
{| class="wikitable"
|-
|-
Line 27: Line 27:
| Returns the amount of functions registered, with an optional name argument ([https://lua.org/manual/5.1/manual.html#5.4 string])
| Returns the amount of functions registered, with an optional name argument ([https://lua.org/manual/5.1/manual.html#5.4 string])
|}
|}
== Fields ==
remove:
# name : [https://lua.org/manual/5.1/manual.html#5.4 string]
register:
# function : [https://www.lua.org/manual/5.1/manual.html#2.5.9 function]
# name : [https://lua.org/manual/5.1/manual.html#5.4 string] (optional)
getRegisteredCount:
# name : [https://lua.org/manual/5.1/manual.html#5.4 string] (optional)

Revision as of 17:46, 26 September 2024

The event type is used for events such as events.TICK. To create an event function, use one of the following.

function events[EVENT]()
end
-- OR
events[EVENT]:register(function()
end) -- optionally as a name argument to allow removal

Methods

Method Description
remove Takes in a string with the name of the event, and removes it, stopping it from being called
clear Clears the event of all methods
register Takes in a function to run when the event is fired, with an optional name argument (string)
getRegisteredCount Returns the amount of functions registered, with an optional name argument (string)

Fields

remove:

  1. name : string

register:

  1. function : function
  2. name : string (optional)

getRegisteredCount:

  1. name : string (optional)