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

Call ("c")

The next events debug.sethook can hook into are function calls. These events fire every time a function is called. The event handler only needs to take one argument, a string. The value of this string will always be "call". To subscribe to function call events, provide debug.sethook with two arguments: the handler function, and the "c" string. Function callback hooks become much more powerful when combined with the info obtained from debug.getinfo. The following code demonstrates this:

function PrintV(x, y, z)  local out = "(" .. x .. ","  out = out .. ", " .. y  out = out .. ", " .. z .. ")"  return outendfunction MagnitudeSq(x, y, z)  local magSq = x * x + y * y + z * z  return magSq;endfunction trace(event) local info = debug.getinfo(2) ...
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