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

Line ("l")

The first type of debug.sethook event is the line event. This event is going to fire every time a line of code is being executed. If you've ever used a debugger that supports breakpoints, this is the functionality that could be used to implement breakpoints.

To subscribe to the line event, provide the debug.sethook function with two arguments, the even handler and the string "l". The handler function needs to take two arguments. The first argument is going to be a string, with the "line" value. The second argument is going to be an integer; this is the line number being executed:

function VectorLength(x, y, z)  local dot = x * x + y * y + z * z  if dot == 0 then    return nil  end  return math.sqrt(dot)endfunction trace(event, line)
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