Error debug

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
cgrossi
Prole
Posts: 21
Joined: Fri May 24, 2013 6:08 pm
Location: Brazil

Error debug

Post 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
Code games. You'll have fun!
User avatar
Inny
Party member
Posts: 652
Joined: Fri Jan 30, 2009 3:41 am
Location: New York

Re: Error debug

Post 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
User avatar
Jasoco
Inner party member
Posts: 3727
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Error debug

Post 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.
User avatar
cgrossi
Prole
Posts: 21
Joined: Fri May 24, 2013 6:08 pm
Location: Brazil

Re: Error debug

Post by cgrossi »

Thank you, guys. I'm very appreciate. I'll try this library.
Code games. You'll have fun!
kclanc
Citizen
Posts: 89
Joined: Sun Jan 29, 2012 6:39 pm

Re: Error debug

Post 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.
Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests