hook/Call

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
m (The third argument on this isn't number, it's actually vararg similiar to hook.Run, same with the return value.)
Line 18: Line 18:
 
}}
 
}}
 
{{Arg
 
{{Arg
|type=vararg
+
|type=any
 
|name=args
 
|name=args
 
|desc=The arguments to be passed to the functions.
 
|desc=The arguments to be passed to the functions.
 
}}
 
}}
 
{{Ret
 
{{Ret
|type=vararg
+
|type=number
 
|desc=return data from hook's call
 
|desc=return data from hook's call
 
}}
 
}}

Revision as of 13:33, 21 October 2013

 hook.Call( )

Contents

Description

Calls hooks associated with the hook name
Calls all hooks until one returns something other than nil then returns that data.

Arguments

string hookName

The hook name.

Arguments

table gamemodeTable

If the gamemode is specified, the gamemode hook will be called, otherwise not.

Arguments

any args

The arguments to be passed to the functions.

Returns

number

return data from hook's call

Examples

Example

Runs function DoSomething, which eventually calls a hook "DoneDoingSomething", triggering the hooked function DoSomethingElse.

function DoSomething()
    --Does something
    hook.Call("DoneDoingSomething")
end

function DoSomethingElse()
    --Does something else, once the hook DoneDoingSomething is called.
    print("Done!")
end

hook.Add("DoneDoingSomething", "Does something else", DoSomethingElse)

DoSomething()

Output:

Done!
Personal tools
Navigation