util.event.off
Shared
Unregisters a previously registered handler from the specified event
Syntax
local status = util.event.off(
name,
exec
)Parameters
| Type | Name | Description |
|---|---|---|
string | name | Name of the event to unsubscribe from |
function | exec | Handler function reference to remove Must be the same function value passed to util.event.on |
Returns
| Type | Name | Description |
|---|---|---|
bool | status | true if the handler was found and removed, false otherwise |
Examples
local function on_player_join(player)
core.engine.print("info", "Player joined:", player)
end
util.event.on("on_player_join", on_player_join)
core.engine.print("info", "Handler removed:", util.event.off("on_player_join", on_player_join))local handler = nil
handler = function(value)
if value == "done" then
util.event.off("on_signal", handler)
end
end
util.event.on("on_signal", handler)