Page 1 of 1

Error debug

Posted: Mon Jun 10, 2013 11:52 am
by cgrossi
Hello, guys.

Does anyone know how to trap an error for debugging? I'm kinda fighting to hunt down some bugs in my project but sometimes I can't understand why any of them are happening...

Thanks

Re: Error debug

Posted: Mon Jun 10, 2013 4:06 pm
by Inny
The Debug Library should have all of what you're looking for in advanced debugging tools. Also handy is the assert function.

A good tactic I do, which requires you turn on the windows console in the config, is put informative print messages in key spots. Anywhere there might be a loop going and you don't want to see tons of spam in that console, use this function instead:

Code: Select all

function log(...)
  if love.keyboard.isDown("rctrl") then
    print(...)
  end
end

Re: Error debug

Posted: Mon Jun 10, 2013 5:14 pm
by Jasoco
Or if you're on OS X or Linux you simply run the project through the love binary located inside the application package. Does the same thing except that it prints to the Terminal instead of a built-in console window.

For instance on OS X:

Code: Select all

/Path/To/love.app/Contents/MacOS/love /Path/To/Project/Love/File/
You then use the print() (Not love.graphics.print()) function in Lua to print messages to the console like mentioned above.

Re: Error debug

Posted: Tue Jun 11, 2013 11:12 am
by cgrossi
Thank you, guys. I'm very appreciate. I'll try this library.

Re: Error debug

Posted: Tue Jun 11, 2013 3:17 pm
by kclanc
If you're a windows user, the love studio debugger (https://bitbucket.org/kevinclancy/love-studio/downloads) traps errors. It works pretty well for debugging locals and upvalues, but not globals.