Debugging in Lua has been a strange experience for me. The debugging tools are not as rich as the Python or C++ tooling I’m accustomed to.

Two useful items are LOVEDEBUG, developed by several members of the community and DataDumper from the lua users wiki.

Since we’ve camped on version 10.2, the current versions floating around won’t work for these projects.

I’m switching the debugger on and off using an environment variable to prevent it to interfere with grading or showing up in a screencast.

I forked a version to maintain 10.2 support and add a couple useful odds and ends. You can grab it here along with more details and links to the original work.

To use it, I set it up as a subrepo under the lib tree in my projects

❯ cat .gitmodules
[submodule "lib/love-debugger"]
	path = lib/love-debugger
	url = ../love-debugger

then add this to the top of main.lua

if os.getenv('USE_LOVE_DEBUG_REPL') == '1' then
    print("Enabling debug support because USE_LOVE_DEBUG_REPL=1")
    require 'lib/love-debugger/lovedebug'
    require 'lib/love-debugger/DataDumper'
end

It’s a small creature comfort that’s saved me quite a bit of printf.


I’m trying on Kev Quirk’s “100 Days To Offload” idea. You can see details and join yourself by visiting 100daystooffload.com.