How can I debug love?

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
lovefirstly
Prole
Posts: 12
Joined: Sun Jun 21, 2015 3:27 pm

How can I debug love?

Post by lovefirstly »

As a new lover, I wirte love code like this:

1. Write a lua file
2. Zip it to xxx.zip
3.Rename it to xxx.love
4.If I have error in it, love's window will show it. Then I have to go back to the first step to modify the lua file, It's too much trouble.

So I want to know if there is a solution to debug love which let me know the error earlier.
User avatar
ivan
Party member
Posts: 1915
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: How can I debug love?

Post by ivan »

2 and 3 can be combined by dragging your game folder onto 'love2d.exe'

There is the 'strict.lua' library (don't think it's a part of Love2D) that raises an error when you use unreferenced global variables.
But in general debugging Lua is not the same as with static languages.

PS. There are probably better debug tools out there, I'd be curious to see what people use.
lovefirstly
Prole
Posts: 12
Joined: Sun Jun 21, 2015 3:27 pm

Re: How can I debug love?

Post by lovefirstly »

ivan wrote:2 and 3 can be combined by dragging your game folder onto 'love2d.exe'

There is the 'strict.lua' library (don't think it's a part of Love2D) that raises an error when you use unreferenced global variables.
But in general debugging Lua is not the same as with static languages.

PS. There are probably better debug tools out there, I'd be curious to see what people use.
Thanks your answer. You said "2 and 3 can be combined by dragging your game folder onto 'love2d.exe". It's means I can drag the xxx.zip onto love2d. But I tried, nothing happen when I drag onto love;'s window.I use XP system and love 0.9.2, it's a problem?
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: How can I debug love?

Post by zorg »

I have a .bat file in love's directory with the line

Code: Select all

love.exe projectfolder
where projectfolder is where a project's main.lua is. I created said .bat file with notepad.
Doubleclicking that will run the game.
For ease of access, i also create a link to it that's on my desktop, so i dont have to navigate through folders.

What this means is that you really dont need to zip/rename it all the time while you're developing the thing. That can be done after you deem your thing finished or at least releaseable.

A few other options:
- Use an IDE like zerobrane studio
- A bit more questionable and slightly harder route would be to use a library that allows code hotswapping, but those have their own disadvantages as well as advantages.
- The hardest would be to create your own hotswapping solution, meaning you get instant feedback on your code changes while it runs

At least, that's my take on things; after trying out these, i decided to just code in sublime text (2), but that fits my own train of thought :3

Edit: edited for clarity
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
User avatar
Jasoco
Inner party member
Posts: 3726
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: How can I debug love?

Post by Jasoco »

Don't even bother zipping the project up until you need to share it. It's just a waste of time during development. You can run the .love from Löve as a folder. There's probably .bat files you could make to run it for you easily. Zipping is a finalization method and isn't required until the time comes. Say you want to share it on the forum or with a friend.

On Windows you'd need to enable the console using its flag in the conf.lua file. That will let you print() stuff out to help debug.

Otherwise you can write GUI based in-game debugging tools as well. It's what I do. I write my own performance graph. Or I'll draw shapes to the screen representing collision boxes. Stuff like that.
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: How can I debug love?

Post by Nixola »

Jasoco wrote:On Windows you'd need to enable the console using its flag in the conf.lua file. That will let you print() stuff out to help debug.
Unless you're using sh/bash in cygwin (my experience) or something that handles stdout correctly (my supposition); setting it to true in that case will prevent you from getting any output in a console.
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
lovefirstly
Prole
Posts: 12
Joined: Sun Jun 21, 2015 3:27 pm

Re: How can I debug love?

Post by lovefirstly »

zorg wrote:I have a .bat file in love's directory
Thanks, Save me a lot of time. :awesome:

write a bat file like this: love.exe %cd%
Kotoromo
Prole
Posts: 1
Joined: Sat Aug 09, 2014 8:14 am
Location: México

Re: How can I debug love?

Post by Kotoromo »

Also, all of your steps could be easily avoided.

If you're using Notepad++, you can follow these instructions:

https://love2d.org/wiki/Notepad%2B%2B

If you're using SublimeText2 or 3, then I suggest you get PackageInstaller plug-in and then search for Lua Love or SublimeLove on PackageControl's Install Package.
Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests