Example
Runs function DoSomething
, which eventually calls the event DoneDoingSomething
, triggering the hooked function DoSomethingElse
.
local function DoSomething()
hook.
Call(
"DoneDoingSomething" )
end
local function DoSomethingElse()
print(
"Done!" )
end
hook.
Add(
"DoneDoingSomething",
"Does something else", DoSomethingElse )
DoSomething()
Example
You can also make custom functions controllable via hooks.
local function MakeCheese()
local shouldMakeCheese
= hook.
Call(
"MakeCheezPleez" )
if shouldMakeCheese
then
print(
"yay" )
else
print(
"nay" )
end
end
local function MakeCheeseOrNot()
return player.
GetCount()
>= 1
end
hook.
Add(
"MakeCheezPleez",
"Does something else", MakeCheeseOrNot )
MakeCheese()
Output: If there is players in the server, we print yay
. If there isn't, we print nay
.
Example
Calls the event DoneDoingSomething
with some arguments.
hook.
Add(
"DoneDoingSomething",
"Does something else",
function( a, b )
print( a )
print( b )
end )
hook.
Call(
"DoneDoingSomething",
nil,
"Hello",
"Hey" )