Is there any way to use the vscode terminal for debugging with love2d?
Is there any way to use the vscode terminal for debugging with love2d?
Im just wondering if there is any way to use the vscode terminal for debugging?is there like an extension or something or some other way to do it.
Re: Is there any way to use the vscode terminal for debugging with love2d?
To make it so you can output message to the terminal with print commands you just need the following line at the start of your main.lua file:
For full debugging (breakpoints and stepping through functions etc.) I use https://marketplace.visualstudio.com/it ... ger-vscode
That takes a bit more setting up and my setup may not be the best, I got it going a while ago have been copying a bese template project ever since so can't quite remember which bits I did anything to and which bits I haven't.
My launch.json I use (this file should be in the .vscode subfolder of your love projects) is:
Then in love.load() I enable the debugger like this:
Finally, for the debugger to catch errors you need to override the love error handler:
Code: Select all
io.stdout:setvbuf("no")
That takes a bit more setting up and my setup may not be the best, I got it going a while ago have been copying a bese template project ever since so can't quite remember which bits I did anything to and which bits I haven't.
My launch.json I use (this file should be in the .vscode subfolder of your love projects) is:
Code: Select all
{
"version": "0.2.0",
"configurations": [
{
"type": "lua-local",
"request": "launch",
"name": "Debug",
"program": {
"command": "love"
},
"args": [
".",
"debug"
],
},
{
"type": "lua-local",
"request": "launch",
"name": "Release",
"program": {
"command": "love"
},
"args": [
".",
],
},
]
}
Code: Select all
-- Enable debugger
debugMode = false
if arg[2] == "debug" then
require("lldebugger").start()
debugMode = true
end
Code: Select all
local loveErrorhandler = love.errorhandler or love.errhand
function love.errorhandler(msg)
if debugMode then
error(msg, 2)
else
return loveErrorhandler(msg)
end
end
Who is online
Users browsing this forum: No registered users and 3 guests