LOVE VSCode Game Template
September 29, 2024 ยท View on GitHub
A fully configured VSCode template for LOVE
Features
- ๐ Rich Lua language features with Lua Language Server
- ๐ง Debugging with Local Lua Debugger
- ๐ข Automatic builds with Makelove
- ๐จโ๐ป Consistent coding styles with Editorconfig
- ๐โโ๏ธ Running scripts with NPM Scripts
- ๐๏ธ Organized with Workspaces
- ๐ Extensible and configurable for your needs
Prerequisites
- Visual Studio Code
- LรVE 11.4
- Makelove
- NPM (Optional)
LรVE and Makelove should be in your PATH environment variable.
Setup
1 - Use this template to create a new repository for your game, then clone that repository locally.
2 - Open the Workspace.code-workspace file with Visual Studio Code.
You will be prompted that there are recommended extensions and if you want to install these. Click 'Install'.
If this does not happen, install Sumneko's Lua extension, Local Lua Debugger and Editorconfig manually.
3 - Configure the Game/conf.lua and Tools/build/makelove.toml with the settings specific for your game.
NOTE: Make sure to keep t.console set to false in love.conf. Local Lua Debugger will not work otherwise.
4 - Configure the Root/.editorconfig to your liking for code styles.
5 - Change the Root/LICENSE file to your liking and/or swap out my name for your name.
In case you need help, feel free to send me (Keyslam) a message in the LรVE Discord server. There's also a bunch of other cool people there who are always willing to help.
Running
Press F5 to launch the game in 'Debug mode'. In debug mode you can use breakpoints and inspect variables. This does have some performance impact though.
You can switch to 'Release mode' in the 'Run and Debug' tab (Ctrl+Shift+D).
Alternatively, you can run lovec game in the terminal, but you will have debugging capabilities.
Structure
โโโ /Game
โ โโโ /assets Contains the game's assets
โ โโโ /lib Contains external libraries
โ โโโ /src Contains the game's source code
โ
โโโ Tools
โ โโโ /build Contains the makelove.toml
โ โโโ package.json Contains all scripts to use with NPM Scripts
โ
โโโ Resources Contains resources for you game that should not be shipped, like raw audio
โ
โโโ Builds Contains the builds of your game made with makelove
โ
โโโ Root Root access to the workspace
Appendix A: Why isn't Pixelbyte Studio's "Love2D support" extension included?
Pixelbyte Studio's "Love2D support" extension is commonly used by beginners because it is the first result that shows up when you search for LรVE extensions in VSCode. However, it doesn't add any features you can't get with a well configured VSCode workspace. It also doesn't work with Local Lua Debugger and gives conflicting Intellisense results with the Lua Language Server.
Appendix B: Setting up a minimal project yourself.
Sometimes you don't want a full blown template and just get the minimum required settings to get your editor working. The following steps will explain how to setup a project with the Sumneko Language Server and a launch task:
-
Create a folder for your game with your
main.luaandconf.lua. -
Open the folder with VSCode.
-
Install the Sumneko Lua Language Server and Local Lua Debugger extensions.
-
In the same folder as your
main.lua, create a folder named.vscode -
In the
.vscodefolder, create a file namedsettings.jsonand copy the following contents into it:
{
"Lua.workspace.library": [
"${3rd}/love2d/library",
"lib"
],
"Lua.runtime.version": "LuaJIT",
"Lua.workspace.checkThirdParty": false,
}
- In the
.vscodefolder, create a file namedlaunch.jsonand copy the following contents into it:
{
"version": "0.2.0",
"configurations": [
{
"type": "lua-local",
"request": "launch",
"name": "Release",
"program": {
"command": "love"
},
"args": [
".",
],
},
]
}
You can use this template as a basis for how to add additional features such as debugging, code styles, folder structures, automatic builds, et cetera.