Global Command: unregisterEventHandler

From The Official Visionaire Studio: Adventure Game Engine Wiki
Revision as of 10:19, 11 August 2023 by EK (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Unregister an event handler for a specific engine event which had been registered before.

Related functions registerEventHandler


Syntax

unregisterEventHandler(eventType, handler)


Parameters

Parameter Type Supported values Description
eventType string "actionArea" The type of event which triggers the event handler.
"animationStarted"
"animationStopped"
"engineEvent"
"keyEvent"
"mainLoop"
"mouseEvent"
"textStarted"
"textStopped"
handler string The name of the function which is called when the event occurs.


Return values

none


Examples

Example 1: Register and unregister an event handler function for the main loop.

local counter = 1

function onMainLoop()
  print(counter)
  
  if counter == 100 then
    unregisterEventHandler("mainLoop", "onMainLoop")
  else
    counter = counter + 1
  end
end

registerEventHandler("mainLoop", "onMainLoop")