Template for Windows Visual Studio Code

Hello, I've created template for Visual Studio Code that will help you with autocompletion and one-button build-and-run task to run your game on the simulator.

P.S. I've added auto-zip feature, if you want your game to automatically zip you will need WinRAR installed and add this text to tasks.json:

{
  "label": "Zip",
  "type": "shell",
  "command": "C:\\Program Files\\WinRAR\\WinRar.exe",
  "args": [
      "a",
      "-afzip",
      "-ep1",
      "'${workspaceFolder}/builds/${workspaceFolderBasename}.zip'",
      "'${workspaceFolder}/builds/${workspaceFolderBasename}.pdx'"
    ],
  "presentation": {
    "showReuseMessage": false,
    "reveal": "always",
    "panel": "shared"
  }
},

And add "Zip" to the dependsOn sequence:
"dependsOn": ["Invoke Build and Run script", "Zip"],

7 Likes

Thank you for the great config! If I may suggest a small adjustment for the settings.json file:

{
    "Lua.runtime.version": "Lua 5.4",
    "Lua.diagnostics.disable": ["undefined-global", "lowercase-global"],
    "Lua.diagnostics.globals": ["playdate", "import"],
    "Lua.runtime.nonstandardSymbol": ["+=", "-=", "*=", "/="],
    "Lua.workspace.library": ["$PLAYDATE_SDK_PATH/CoreLibs"],
    "Lua.workspace.preloadFileSize": 1000
}
2 Likes

Thank you, I've uploaded in to the repo.
By the way, I'm using additional disabled diagnostics "unused-function" in my project that use OOP.

1 Like

Great, thanks for updating it! I think, it could be nice to also update the other files to make them use the env variable name recommended in the doc "PLAYDATE_SDK_PATH" instead of "PLAYDATE_SDK".

I've changed PLAYDATE_SDK to PLAYDATE_SDK_PATH in the repo.

1 Like
  • Updated .cmd file (now it's called ADD_ENV_VARIABLE.cmd) so it points to /bin folder, like new 1.9.0 docs suggests, so I've rewritten tasks.json to use /bin variable instead.
  • Documented main.lua file
1 Like

You saved me a lot of time, thanks a lot! :slight_smile:

1 Like

Have a look at my other library, which will also save you a lot of time:

I also managed to use the tasks on macOS after some tinkering.

VSCode allows platform specific commands. So after disabling the closeSim.ps1, I updated some tasks:

           {
		"label": "Clean",
		"type": "shell",
		"windows": { 
			"command": "Remove-Item",
			"args": [
		  	"'${workspaceFolder}\\builds\\*'",
		  	"-Recurse",
		  	"-Force"
			],
		},
		"osx" : {
			"command": "rm",
			"args": ["-Rf","'${workspaceFolder}/builds/*'"]
		},
		"group": { "kind": "none", "isDefault": true },
		"presentation": {
		  "showReuseMessage": false,
		  "reveal": "always",
		  "panel": "shared"
		}
	  },
          {
		"label": "Run (Simulator)",
		"type": "shell",
		"windows": {
			"command": "${env:PLAYDATE_SDK_PATH}/bin/PlaydateSimulator.exe",
			"args": ["'${workspaceFolder}/builds/${workspaceFolderBasename}.pdx'"],
		},
		"osx": {
			"command": "open",
			"args": ["'${workspaceFolder}/builds/${workspaceFolderBasename}.pdx'"],
		},
		"presentation": {
		  "showReuseMessage": false,
		  "reveal": "always",
		  "panel": "shared"
		}
	  },

and it works :ok_hand:

3 Likes

Thank you for this template, it's boosting my game develop.
I tried to make something similar on VS2019 but yours is much better.

1 Like

Wondering about your tinkering process to install in detail if you have a moment, as I am trying to install after starting that intro tutorial from SquidGodDev.

How did you disable closeSim.ps1? By deleting it? Then, where did you update the tasks?

Here's my complete task file. Works on Windows and macOS. I just close the simulator manually.

{
	// See https://go.microsoft.com/fwlink/?LinkId=733558
	// for the documentation about the tasks.json format
	"version": "2.0.0",
	"tasks": [
	  {
		"label": "Clean",
		"type": "shell",
		"windows": { 
			"command": "Remove-Item",
			"args": [
		  	"'${workspaceFolder}\\builds\\*'",
		  	"-Recurse",
		  	"-Force"
			],
		},
		"osx" : {
			"command": "rm",
			"args": ["-Rf","'${workspaceFolder}/builds/*'"]
		},
		"group": { "kind": "none", "isDefault": true },
		"presentation": {
		  "showReuseMessage": false,
		  "reveal": "always",
		  "panel": "shared"
		}
	  },
	  {
		"label": "Build",
		"type": "shell",
		"command": "pdc",
		"args": [
		  "-sdkpath",
		  "${env:PLAYDATE_SDK_PATH}",
		  "'${workspaceFolder}/source'", // source folder
		  "'${workspaceFolder}/builds/${workspaceFolderBasename}.pdx'" // output file
		],
		"options": {
		  "cwd": "${env:PLAYDATE_SDK_PATH}" // run from sdk folder to ensure imports work
		},
		"presentation": {
		  "showReuseMessage": false,
		  "reveal": "always",
		  "panel": "shared"
		}
	  },
	  {
		"label": "Close Existing Sim",
		"type": "shell",
		"command": "${workspaceFolder}\\closeSim.ps1",
		"args": [],
		"presentation": {
		  "showReuseMessage": false,
		  "reveal": "always",
		  "panel": "shared"
		}
	  },
	  {
		"label": "Run (Simulator)",
		"type": "shell",
		"windows": {
			"command": "${env:PLAYDATE_SDK_PATH}/bin/PlaydateSimulator.exe",
			"args": ["'${workspaceFolder}/builds/${workspaceFolderBasename}.pdx'"],
		},
		"osx": {
			"command": "open",
			"args": ["'${workspaceFolder}/builds/${workspaceFolderBasename}.pdx'"],
		},
		"presentation": {
		  "showReuseMessage": false,
		  "reveal": "always",
		  "panel": "shared"
		}
	  },
	  {
		"label": "Build and Run (Simulator)",
		"dependsOn": ["Clean", "Build"/*, "Close Existing Sim"*/, "Run (Simulator)"],
		"dependsOrder": "sequence",
		"presentation": {
		  "showReuseMessage": false,
		  "reveal": "always",
		  "panel": "shared"
		},
		"problemMatcher": [],
		"group": {
		  "kind": "build",
		  "isDefault": true
		}
	  },
	  {
		"label": "Test (Simulator)",
		"dependsOn": [/*"Close Existing Sim", */"Run (Simulator)"],
		"dependsOrder": "sequence",
		"presentation": {
		  "showReuseMessage": false,
		  "reveal": "always",
		  "panel": "shared"
		},
		"problemMatcher": [],
		"group": {
		  "kind": "test",
		  "isDefault": true
		}
	  }
	]
  }