debug/sethook

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
m
m (Also menu state)
 
(3 intermediate revisions by one user not shown)
Line 1: Line 1:
 
{{Func
 
{{Func
 +
|Description=Sets the given function as a Lua hook. This is completely different to gamemode hooks. The thread argument can be completely omitted and calling this function with no arguments will remove the current hook. This is used by default for infinite loop detection. More information on hooks can be found at http://www.lua.org/pil/23.2.html
 +
 +
Hooks are not always ran when code that has been compiled by LuaJIT's JIT compiler is being executed. This means that relying on them for infinite loop protection is unwise.
 +
|Realm=Shared and Menu
 +
|IsClass=No
 
|Name=sethook
 
|Name=sethook
 
|Parent=debug
 
|Parent=debug
|Description=Sets the given function as a Lua hook. This is completely different to gamemode hooks. The thread argument can be completely omitted and calling this function with no arguments will remove the current hook. This is used by default for infinite loop detection. More information on hooks is available at http://www.lua.org/pil/23.2.html
 
|Realm=Shared
 
|IsClass=No
 
 
}}
 
}}
 
{{Arg
 
{{Arg
Line 24: Line 26:
 
|type=number
 
|type=number
 
|name=count
 
|name=count
|desc=How often to call the hook (in instructions). 0 for infinite
+
|desc=How often to call the hook (in instructions). 0 for every instruction
 
}}
 
}}

Latest revision as of 02:49, 24 July 2016

 debug.sethook( )

Contents

Description

Sets the given function as a Lua hook. This is completely different to gamemode hooks. The thread argument can be completely omitted and calling this function with no arguments will remove the current hook. This is used by default for infinite loop detection. More information on hooks can be found at http://www.lua.org/pil/23.2.html

Hooks are not always ran when code that has been compiled by LuaJIT's JIT compiler is being executed. This means that relying on them for infinite loop protection is unwise.

Arguments

thread thread

Thread to set the hook on. This argument can be omited

Arguments

function hook

Function for the hook to call

Arguments

string mask

The hook's mask

Arguments

number count

How often to call the hook (in instructions). 0 for every instruction
Personal tools
Navigation