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 and follow me on twitter here.

7 Comments

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.

Paul.

@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?

Leave a comment

what will you say?
(required)
(required)

About

I am Paul Kulchenko.
I live in Kirkland, WA with my wife and three kids.
I do consulting as a software developer.
I study robotics and artificial intelligence.
I write books and open-source software.
I teach introductory computer science.
I develop a slick Lua IDE and debugger.

Recommended

Close