Event (type)

From FiguraMC
Revision as of 17:30, 26 September 2024 by TheKillerBunny (talk | contribs) (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...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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