Unofficial Playdate debug extension for Visual Studio Code
- Debug Lua code running in the Playdate Simulator
- Compile games to
.pdx
usingpdc
- Problem matchers for
pdc
- Open the Playdate Simulator
- The Playdate SDK must be installed separately
Use cookiecutter and cookiecutter-playdate to quickly create a project skeleton.
- Click on the debug icon (play symbol with a bug) in the toolbar to open the "Run and Debug" view
- Click the link that says
Create a launch.json file
- Select
Playdate Debug
in the dropdown to create the configuration in.vscode/launch.json
- (Optional) Run the default build task before debugging by setting the
preLaunchTask
property in theDebug (Simulator)
configuration:
"preLaunchTask": "${defaultBuildTask}"
Your .vscode/launch.json
should now look like this:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "playdate",
"request": "launch",
"name": "Debug (Simulator)",
"preLaunchTask": "${defaultBuildTask}"
}
]
}
- Enter
Cmd/Ctrl + Shift + P
on the keybord to open the Command Palette - Type
Configure Task
and hit enter - Select
Playdate: Build
in the dropdown to add it to.vscode/tasks.json
- Enter
Cmd/Ctrl + Shift + P
on the keybord to open the Command Palette - Type
Configure Task
and hit enter - Select
Playdate: Simulator
in the dropdown to add it to.vscode/tasks.json
- Open
.vscode/tasks.json
- Paste the following configuration into the
tasks
array after thePlaydate: Simulator
task:
{
"label": "Playdate: Build and Run (Simulator)",
"dependsOn": ["Playdate: Build", "Playdate: Simulator"],
"dependsOrder": "sequence"
}
- Enter
Cmd/Ctrl + Shift + P
on the keybord to open the Command Palette - Type
Configure Default Build Task
and hit enter - Select
Playdate: Build and Run (Simulator)
in the dropdown
Your .vscode/tasks.json
file should now look like this:
{
"version": "2.0.0",
"tasks": [
{
"type": "pdc",
"problemMatcher": ["$pdc-lua", "$pdc-external"],
"label": "Playdate: Build"
},
{
"type": "playdate-simulator",
"problemMatcher": ["$pdc-external"],
"label": "Playdate: Simulator"
},
{
"label": "Playdate: Build and Run (Simulator)",
"dependsOn": ["Playdate: Build", "Playdate: Simulator"],
"dependsOrder": "sequence",
"problemMatcher": [],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
The tasks and debugger will attempt to automatically resolve the correct configuration using the environment. The following configuration must exist for this to work:
- Either of the following:
~/.Playdate/config
exists and theSDKRoot
property is set to the Playdate SDK path- The
PLAYDATE_SDK_PATH
environment variable is set to the Playdate SDK path
- The Playdate SDK
bin
directory is in yourPATH
- A pdxinfo file exists in your game's
source
directory and thename
property is set
The default behavior can be overridden by setting the SDK path, game source path, compiled game path or game name in your workspace's settings.json
file. The extension will fall back to the default behavior for any configuration fields that are not set.
// .vscode/settings.json
{
"sdkPath": "/path/to/PlaydateSDK",
"sourcePath": "/path/to/MyGame/source",
"outputPath": "/path/to/MyGame",
"productName": "My Game"
}
The Playdate Simulator task launches the Playdate Simulator once and leaves it running in the background by default. The kill
property can be used to instead have the task stop running instances of the Playdate Simulator before launching a new one.
// .vscode/tasks.json
{
"version": "2.0.0",
"tasks": [
{
"type": "playdate-simulator",
"problemMatcher": ["$pdc-external"],
"label": "Playdate: Simulator",
"kill": true
}
]
}
- Debugging is not supported on Windows or Linux.
make
andcmake
-based projects are not supported.- Breakpoints are in an unverified state.
- Stepping into C functions causes the debugger to continue executing.