Global Command: unregisterEventHandler

From The Official Visionaire Studio: Adventure Game Engine Wiki
Revision as of 21:40, 11 May 2023 by EK (talk | contribs) (Created page with "Unregister an event handler for a specific engine event which had been registered before. {| class="ts" |- | style="width:15%" | Related functions | Global Command: registe...")
(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")