How to Debug LOVE Program?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
How to Debug LOVE Program?
That so Happy to program with LOVE, but when the program is bigger and bigger,How we can control the bug?I mean Debug the LOVE program.As I know,LUA don't have a good debug program,SciTE's debug function is not so good as gdb or VS.But It can be used.But how to Debug LOVE Program?
- Taehl
- Dreaming in associative arrays
- Posts: 1025
- Joined: Mon Jan 11, 2010 5:07 am
- Location: CA, USA
- Contact:
Re: How to Debug LOVE Program?
Depends on what, exactly, you want to debug. Myself, I generally like throwing debug messages on the screen, so I can watch my variables in-game. For instance, right now I have:
Code: Select all
-- Print debug data
love.graphics.print("tiles: "..tilecount(), 12, 12)
love.graphics.print("bgtiles: "..bgtilecount(), 12, 26)
love.graphics.print("fps: "..love.timer.getFPS(), screen.x-62, 12)
love.graphics.print("tiles carried: "..player.tiles.."/16", screen.x-115, 26)
message = "Player's arms touch: "
if not player.armstouch then message = message.."No"
else message = message..math.round(player.armstouch.x)..", "..math.round(player.armstouch.y)
end
message = message.."\nPlayer's legs touch: "
if not player.legstouch then message = message.."No"
else message = message..math.round(player.legstouch.x)..", "..math.round(player.legstouch.y)
end
message = message.."\nPlayer's action: "..player.action.." "..player.direction
love.graphics.print(message, 60, screen.y-101)
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
Re: How to Debug LOVE Program?
Is that means if you want to know which the branch the program goes,you should add log print out in every branch(every if ?)That's so inconvenience.
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: How to Debug LOVE Program?
branches?
And it normally helps if you just add a debug print statement for some important lines, then at least you know where to add extra debugs when something doesn't work out.
And wanted to add that this is a lua problem, really, not a love one.
And it normally helps if you just add a debug print statement for some important lines, then at least you know where to add extra debugs when something doesn't work out.
And wanted to add that this is a lua problem, really, not a love one.
Re: How to Debug LOVE Program?
That's a easy thing to make a console debug program for lua,because lua have a built-in debug mechanism.But the gui debug program need too much time to make and there is not a good enough one.
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: How to Debug LOVE Program?
Instead of using a love-related function (such as love.print) I just use the regular lua print function
This will print on the console - which is fine for me (you will get lots of messages if you print on each update() call)
On windows you will have to set up one flag in order to show these messages. On linux it'll work "out of the box", sending the messages to the console. Don't know about the Mac version.
Debugging is the main reason I've switched to the Ubuntu version from windows - it is easier for me.
Code: Select all
print('my debug message')
On windows you will have to set up one flag in order to show these messages. On linux it'll work "out of the box", sending the messages to the console. Don't know about the Mac version.
Debugging is the main reason I've switched to the Ubuntu version from windows - it is easier for me.
When I write def I mean function.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: How to Debug LOVE Program?
What I often find useful is to have a log function:
and set dbg = true at the top of main.lua.
When you want to release your game, just remove the first line.
Code: Select all
function log(...)
if dbg then print(...)
end
When you want to release your game, just remove the first line.
Help us help you: attach a .love.
Re: How to Debug LOVE Program?
I once had a plan to release a 100% plain Lua library version of LÖVE (e.g. a love.dll loadable in normal Lua scripts). The LÖVE source does support this as of 0.6.0 (LOVE_BUILD_DLL vs LOVE_BUILD_EXE) in theory, but I've never actually tried it.
The whole point was to enable people to use existing debugger tools for Lua, like LuaEdit, which has a graphical debugger.
The whole point was to enable people to use existing debugger tools for Lua, like LuaEdit, which has a graphical debugger.
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: How to Debug LOVE Program?
One word: automake.
Who is online
Users browsing this forum: Ahrefs [Bot], Semrush [Bot] and 2 guests