Garry's Mod Wiki

Revision Difference

debug.sethook#549019

<function name="sethook" parent="debug" type="libraryfunc"> <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⤶ 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 and https://www.gammon.com.au/scripts/doc.php?lua=debug.sethook⤶ 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. </description> <realm>Shared and Menu</realm> <args> <arg name="thread" type="thread">Thread to set the hook on. This argument can be omited</arg> <arg name="hook" type="function">Function for the hook to call</arg> <arg name="mask" type="string">The hook's mask</arg> <arg name="count" type="number">How often to call the hook (in instructions). 0 for every instruction</arg> </args> </function>