按 CTRL + SHIFT + P
,打开Preferences: Open User Settings (JSON)
,为settings.json添加如下代码
"Lua.runtime.version": "LuaJIT",
"Lua.diagnostics.globals": [
"love",
],
"Lua.workspace.library": [
"${3rd}/love2d/library"
],
"Lua.workspace.checkThirdParty": false,
到Run and Debug
配置launch.json
,该文件将出现在你工作目录下的 .vscode 文件夹
{
"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": [
".",
],
},
]
}
if arg[2] == "debug" then
require("lldebugger").start()
end
出错信息不会显示在游戏窗口画面上,而是直接定位到当前错误的行
local love_errorhandler = love.errhand
function love.errorhandler(msg)
if lldebugger then
error(msg, 2)
else
return love_errorhandler(msg)
end
end
修改conf.lua
,关闭t.console
,否则调试器会无法获取到信息而卡住
-- conf.lua
love.conf = function(t)
-- t.console = true
end
按F5启动游戏,你现在可以选择两种方式来启动
如果出现提示 '"love"' �����ڲ����ⲿ���Ҳ���ǿ����еij��� ���������ļ���
只需要重启VSCODE
tomblind/local-lua-debugger-vscode: Local Lua Debugger for VSCode (github.com)
if arg[2] == "debug" then
require("lldebugger").start()
end
-- your code
local love_errorhandler = love.errhand
function love.errorhandler(msg)
if lldebugger then
error(msg, 2)
else
return love_errorhandler(msg)
end
end
{
"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": [
".",
],
},
]
}
手机扫一扫
移动阅读更方便
你可能感兴趣的文章