Löve debugging with ZeroBrane Studio

Löve is a simple and powerful framework for developing 2D games in Lua, which makes it a natural fit to support in ZeroBrane Studio. The just released version of ZeroBrane Studio (v0.30) implements debugging and auto-complete support for löve scripts; the video below demonstrates these capabilities (you may need to switch the video to 720p to make the text more readable):

To enable the integration shown in the demo, you need to do few things:

  • Copy the debugger (src/lualibs/mobdebug/mobdebug.lua) to the folder with löve executable (in the demo it is d:\lua\love folder). (This step is no longer needed if you use ZeroBrane Studio v0.31 or later)
  • Add if arg[#arg] == "-debug" then require("mobdebug").start() end line to your script somewhere inside love.load(arg) function. This will allow you to use Project | Run command to run the application and Project | Start Debugging to debug your application.
  • Select love2d as an interpreter in ZeroBrane Studio going to Program | Lua Interpreters | Love2d. In addition to enabling debugging, it will also turn on auto-complete for löve API calls. If löve executable is in the same folder where your game folders are or in one of the folders listed in PATH, it will be found by the IDE. If the executable is in a different location, you may need to specify this location in cfg/user.lua file (see cfg/user-sample.lua for details on how this is done).

You can now open main.lua file from your project in the IDE and work with your creation.

You should get a copy of my slick ZeroBrane Studio IDE.


How come when I use the debug tool it crashes love, and zbstudio.exe if i run the file in console to work out what's happening?

Not sure; is there anything I can try to reproduce? ZBS is usually resilient to app crashes as it runs in a separate process. What platform are you on? Is there a small project I can try on? Do you do anything in particular when it crashes? Do other scripts work? You can email me the details; my address is at the bottom of the page.


@someone from Love2d.org: I may know what may be causing the crash. Try adding "socket.select = function() return {} end" after "require('mobdebug').start()".

One possible reason for the crash is that ZBS is using luasocket DLLs compiled using mingw compiler, but love2d is compiled using Visual Studio. I noticed that in some rare cases this mix causes a crash when socket.select call is used (which happens in the debugger). I'm exploring fixes for this issue.

Hi. I want to ask whether is it possible to view Love output window when running love program from ZeroBrane Studio ? When I start the program from console the command is "love --console " but I don't know how to integrate it with ZeroBrane.

Ivan, yes, it's possible. I provided details on how this can be done in this forum post: https://love2d.org/forums/viewtopic.php?f=3&t=9762&p=159645#p159645

Love2D still crashes on debug, and the workaround you gave doesn't seem to work.

@Teraku, yes, the workaround is not going to change anything in the recent versions of ZeroBrane Studio as it's been incorporated into the code itself: the debugger no longer uses socket.select calls that were deemed to be related to the crashes.

Do you have any more details on the crashes? Maybe a simple script you can demonstrate it on so that I could troubleshoot it? Are you using love 0.9?

I'm also having the love2d crash with debug. As soon as it hits the require for the debugger, the love window crashes. I would add a code sample but it does it even when simply defining empty callbacks. If I allow windows to recover the window, it gives an error that the debugger connection closed.

Windows 7 x64

@DmL, what versions of Love and ZeroBrane Studio are you using? Does it crash when you try to debug the example that ships with ZBS (myprograms/love2d-samples/*)? For example, try setting a breakpoint on love.keyreleased in love2d-samples/shooter.

ZeroBrane Studio (0.95; MobDebug 0.613), newly released LOVE 0.9.2. Windows 8.1.

Normal execution works fine. Debug execution creates love game window, then the window freezes. Doesn't matter if I use the 64 or 32 bit love executables. Freeze happens even in the barebones hello love2d example included with zerobrane.

@Clavus, this "freeze" may mean that the debugging is stopped on the first statement in your love2d script. You can simply continue the debugging by switching to ZBS and using Continue/F5. If you don't want the debugging to be stopped on the first statement, you can use "debugger.runonstart=true" setting in the config file.

Oh wow that was exactly the issue. Thanks! Maybe a bit confusing that it does that by default? Another thing I had to figure out was that if I put a breakpoint on an empty line, the program doesn't halt at that point, you have to place it on a line containing a statement (maybe let a breakpoint on an empty line trigger automatically at the first preceding statement?). Anyway, really like ZeroBrane so far. Looks to be a great addition to my workflow!


I'm trying to debug a certain script in love2d. I have a certain variable that is inside the player table, player.currentArmQuad. I can see my dt variables outside of this table fine with debugging but I can't find out how to see inside any variables inside a table. How do I see inside these?



Leave a comment

what will you say?