Page 1 of 1
Using LÖVE with Visual Studio Code
Posted: Wed Apr 01, 2020 10:33 am
by Nekyia
Hello,
I start learning Lua and plan to make games with LÖVE. I want to code with Visual Studio Code.
I have installed and set up 'Code Runner' to launch lua53.exe (lua-5.3.5_Win64_bin) and vscode-lua for Intellisense and Linting.
I see two plugins for LOVE: LOVE by bschulte and Love2D Support by Pixelbyte Studios.
- Should I use another version of Lua?
- I have installed the first plugin. Would you recommand this one rather than the other one?
- And how can I make luacheck work with LÖVE?
Thank you!
Edit: Also installed Lua Debug, which can obviously be helpful
Re: Using LÖVE with Visual Studio Code
Posted: Sun Apr 05, 2020 8:52 pm
by tobiasvl
You don't actually need Lua installed to run LÖVE games. LÖVE comes with everything you need, and by default it uses the LuaJIT interpreter, not Lua 5.3. Launching your LÖVE games in lua53.exe is not going to work; you need to run them with the LÖVE framework.
You can use an extension like Löve Launcher by Jan Werder to do so easily. The one by Pixelbyte Studios also supports launching the project in LÖVE (it is the one I use, I haven't used the one by bschulte).
luacheck and Lua Debug will work with LÖVE as well, but they're going to tell you that "love" is undefined, for example. Not sure if there's a way to fix that, so I just ignore it.
Re: Using LÖVE with Visual Studio Code
Posted: Sun Apr 05, 2020 11:54 pm
by scoobyff666
Dont forget there is the Local Lua Debugger (tomblind.local-lua-debugger-vscode) extension.
This extension will debug love games with break points and all the cool stuff.
Re: Using LÖVE with Visual Studio Code
Posted: Sat Apr 11, 2020 9:22 am
by Nekyia
Thanks to both of you! That was really helpful and I have now everything I need to learn and make games
Re: Using LÖVE with Visual Studio Code
Posted: Mon Apr 13, 2020 7:49 am
by tobiasvl
scoobyff666 wrote: ↑Sun Apr 05, 2020 11:54 pm
Dont forget there is the Local Lua Debugger (tomblind.local-lua-debugger-vscode) extension.
This extension will debug love games with break points and all the cool stuff.
Wow, I actually hadn't used this. It seems super useful, but doing require("lldebugger").start() is really resource intensive, it seems. My game drops to about 1 FPS. Also, on Windows, even though I use lovec.exe in the launch.json (and t.console is true, of course), the console window doesn't appear.
Re: Using LÖVE with Visual Studio Code
Posted: Tue Apr 14, 2020 6:36 pm
by Nekyia
I put that in user settings.json:
Code: Select all
"launch": {
"configurations":
[
{
"type": "lua-local",
"request": "launch",
"name": "Debug LOVE",
"program":
{
"command": "love"
},
"args":
[
"${workspaceFolder}",
"vsc_debug"
],
},
]
},
It sends "vsc_debug" as argument and I have this is the first line of my main.lua :
Code: Select all
if arg[#arg] == "vsc_debug" then require("lldebugger").start() end
But the main point is that I had to put the configuration inside user settings. I don't remember why
Re: Using LÖVE with Visual Studio Code
Posted: Tue Apr 14, 2020 9:55 pm
by scoobyff666
Well, this may help some people. I put the following lines as the first lines in my main.lua:
Code: Select all
if pcall(require, "lldebugger") then require("lldebugger").start() end
if pcall(require, "mobdebug") then require("mobdebug").start() end
So that this works if you're using vscode and also works for people who choose to use the zerobrane debugger.
Wow, I actually hadn't used this. It seems super useful, but doing require("lldebugger").start() is really resource intensive, it seems. My game drops to about 1 FPS. Also, on Windows, even though I use lovec.exe in the launch.json (and t.console is true, of course), the console window doesn't appear.
Yes it is really expensive. By running this code snippet above, you can still run your game by just running love on the terminal, as you would normally do without this vscode extension, and the debugger will not kick in, making the game perform normally. You can also add protection by a command line argument, like Nekyia suggested, so you can create a rule in vscode that will run without debugging. (I don't use windows so I cannot help about the terminal in windows part, sorry)
Re: Using LÖVE with Visual Studio Code
Posted: Wed Apr 15, 2020 8:07 am
by Nekyia
My love2d extension run 'love --console .' Is this similar to lovec.exe ?
I tried lovec.exe and can't see any difference.
Re: Using LÖVE with Visual Studio Code
Posted: Wed Apr 15, 2020 2:32 pm
by pgimeno
Nekyia wrote: ↑Wed Apr 15, 2020 8:07 am
My love2d extension run 'love --console .' Is this similar to lovec.exe ?
I tried lovec.exe and can't see any difference.
I don't have Windows, so I can't tell for sure, but I believe lovec.exe is a "console application", meaning it's the OS who creates and attaches the console, while with love --console, it's Löve itself the one creating and attaching the console. I remember an old thread where the latter caused problems with some editor (Sublime?); maybe it's not the case for VSC or maybe that issue is fixed in a newer version.
Re: Using LÖVE with Visual Studio Code
Posted: Thu Jul 16, 2020 3:23 pm
by davidgallagher
Hi everyone,
I'm new to coding and just trying to get set up with a Lua/LOVE2D debugger in VS Code on a MacBook Pro. I don't understand anything about JSON, executables, etc. and just want to get Lua Love Debugger by Tom Blind up and running so that I can debug. Could someone please walk me through the steps I need to do to get set up. I'm currently using Love2D Support by Pixelbyte Studios to run the programs, but it doesn't appear to have a debugger for Mac.
Thanks!