Multiple hooks

Multiple hooks can be specified by adding a space and another letter to debug.sethook. For example, you could subscribe to every possible event, like so:

debug.sethook(trace, "l c r", 1)

When subscribing to multiple hooks, remember the callback's second argument is nil, except for the line event. Check for nil as appropriate. The following code demonstrates how to do this:

function trace(event, line)
local info = debug.getinfo(2)
if info.what == "Lua" then
print ("event: " .. event)
print (" function: " .. info.name)
print (" defined on: " .. info.linedefined)
if line ~= nil then
print (" called from: " .. line)
end
end
end
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.80.100