Class Hook
Hook Management class.
Creating multiple hooks become more easier.
-
.hookLink
-
The hook doubly-linked list.
- _previous
.hookLink
The previous link.
- _current
function
The hook function.
- _next
.hookLink
The next link.
-
.hookIndexPage
-
The hook index page table.
- _container
table
The hook container parent table.
- _base
table
The base hook class.
- _name
string
The hook name.
- _first
.hookLink
The first hook.
- _last
.hookLink
The last hook.
-
.hookContainer
-
The hook container table.
-
.hookContainerMetatable
-
The hook container's metatable.
- __hookNameComparator
string, string[] or function
The comparator of hook method name (Lua Regex | Hook name list | Comparator function). (default "[Oo]n%u.*")
(optional)
- __functionSelfOverride
bool
Sets hook table as
self
when accessing base's functions.
(default false)
-
Hook.RETURN
-
Hook function return codes.
Fields:
- CONTINUE
Returned when a hook function has not handled the call.
- HANDLED
Returned when a hook function has handled the call.
-
Hook:Create (base[, hookNameComparator[, functionSelfOverride=false]])
-
Creates a hook container.
Parameters:
- base
table
The base hook class.
- hookNameComparator
string, string[] or function
The comparator of hook method name (Lua Regex | Hook name list | Comparator function). (default "[Oo]n%u.*")
(optional)
- functionSelfOverride
bool
Sets hook table as
self
when accessing base's functions.
(default false)
Returns:
.hookContainer
A hook container.
-
Hook:Remove (hooks, func)
-
Removes a hook.
Parameters:
- hooks
table
The hook name.
- func
function or table
The hook function reference to remove.
Returns:
boolean
Returns true
if succeed. Otherwise, returns false
.
-
Hook:RemoveAll (hooks)
-
Removes all hooks.
Parameters:
- hooks
table
The hook name.
Returns:
boolean
Returns true
if succeed.