Skip to Content
Lua Quick Start Guide
book

Lua Quick Start Guide

by Gabor Szauer
July 2018
Beginner
202 pages
5h 42m
English
Packt Publishing
Content preview from Lua Quick Start Guide

Hooks

Lua provides hooks to monitor an application running in real time. An event handler function can be registered to be executed every time an event or hook happens. There are four types of events that can be hooked into:

  • line: called every time a line of code is executed
  • call: called every time a new function is called
  • return: called every time a function returns
  • counter: called every x number of instructions, where the caller specifies x.

To register for line, call or return, call debug.sethook with a handler function and the first letter of the event being hooked into. For example, registering for call events would look like this: debug.sethoof(function, "c"). The event handler function should take one argument in all cases, except ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Beginning Lua Programming

Beginning Lua Programming

Kurt Jung, Aaron Brown
Vim Masterclass

Vim Masterclass

Jason Cannon

Publisher Resources

ISBN: 9781789343229Supplemental Content