Debug with Lua, LOVE, VS Code

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
Nekyia
Prole
Posts: 8
Joined: Thu Aug 03, 2017 4:25 pm

Debug with Lua, LOVE, VS Code

Post by Nekyia »

Hello! :awesome:

I would like to know how you approach debbuging with LOVE ?
I am using VS Code with the plugin 'tomblind.local-lua-debugger-vscode'. I started briefly with ZeroBrane Studio and the debugger worked very well, but was much more happy with vs code.
I would like to uninstall zbs, but still use it occasionaly for the Local Console. My problem with vs code is that often the debugger doesn't seem to work. For example I would set a breakpoint and the debugging will ignore it. Or it refuses to display the variable names.
I end up using a lot of print() and feel like I am wasting a lot of time on debug.

Also how do you debug graphically? Do you add lines in the middle of the code? Write functions, that you may removed later?

In many game you can open a console and show stuff and control parameters with cvars. I am aware of the LoveDebug library, but my skills are limited and I would rather do some games before coding a console system tailor-made.

Sometimes I run the debuger and find the problem immediatly, but mostly it is just print()
I feel inefficient and it is very frustrating.

I am curious about how more experienced and smarter people do it?
User avatar
D0NM
Party member
Posts: 250
Joined: Mon Feb 08, 2016 10:35 am
Location: Zabuyaki
Contact:

Re: Debug with Lua, LOVE, VS Code

Post by D0NM »

Just putting this old topic of yours here
https://love2d.org/forums/viewtopic.php ... 0&p=234856

I remember running Love2D with VSC...
but the break point used to work once. I wasn't able to continue debugging. So I dropped the idea of debugging Love2D with VSC.
Our LÖVE Gamedev blog Zabuyaki (an open source retro beat 'em up game). Twitter: @Zabuyaki.
:joker: LÖVE & Lua Video Lessons in Russian / Видео уроки по LÖVE и Lua :joker:
sphyrth
Party member
Posts: 260
Joined: Mon Jul 07, 2014 11:04 am
Contact:

Re: Debug with Lua, LOVE, VS Code

Post by sphyrth »

I don't have a Rubber Duck with me, so I use that Inefficient Style you mentioned.
User avatar
D0NM
Party member
Posts: 250
Joined: Mon Feb 08, 2016 10:35 am
Location: Zabuyaki
Contact:

Re: Debug with Lua, LOVE, VS Code

Post by D0NM »

Yo!
I just re-installed VSCode
I was looking at https://love2d.org/forums/viewtopic.php?t=88570

So, the new Lua debugger 'lldebugger' works like 3x faster than the 'mobdebug' in ZeroBrane Studio.

What do you need to make it working?
1. Add path to love.exe into your windows env
2. Install these VSC extentions: Local Lua Debugger by Tom Blind, LOVE by bschulte, Lua by sumneko.
3. add debugging config into launch.json (it is described in the Local Lua Debugger info page with LOVE2D example)
4. Select your config in "Run and Debug"
5. Press F5 :joker:

Here is my config

Code: Select all

        {
            "type": "lua-local",
            "request": "launch",
            "name": "Debug LOVE",
            "program":
            {
                "command": "love"
            },
            "args": 
            [
                "${workspaceFolder}",
                "vsc_debug"
            ],
        },
also I load the debugger in main.lua

Code: Select all

if arg[#arg] == "vsc_debug" then require("lldebugger").start() end
Our LÖVE Gamedev blog Zabuyaki (an open source retro beat 'em up game). Twitter: @Zabuyaki.
:joker: LÖVE & Lua Video Lessons in Russian / Видео уроки по LÖVE и Lua :joker:
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest