TUTORIAL: Compiling Lua projects on Windows

This is a basic beginners tutorial for those that need help compiling Lua projects for Playdate on Windows. Essentially all you need to do is run the Playdate SDK file "pdc.exe" on your game folder that contains your "main.lua" file. However, this will not work correctly if you don't set up your System Environment Variables first. Here is a step by step guide on how to do it on Windows:

1. Hopefully you have already installed the Playdate SDK. By default, the install path is "C:\Users\username\Documents\PlaydateSDK". Navigate to the folder in your Windows Explorer, and copy the path.

2. Press the Windows key and type "path" to find the "Edit the system variables" option.

3. Click "Environment Variables" in the bottom right.

step2

4. Click "New" under the System Variables section.

5. Set the "Variable name" to PLAYDATE_SDK_PATH and set the "Variable value" to your Playdate SDK folder, which should be C:\Users\username\Documents\PlaydateSDK

step12

6. I would also recommend adding the bin folder to your Path as well. This way you can run "pdc" from anywhere in the command prompt. Double click the "Path" item (highlighted blue) under the "System variables" section.

7. Click "New" and add the path to your Playdate SDK bin folder. By default it should be C:\Users\username\Documents\PlaydateSDK\bin

8. Now you should have your System Environment Variables set up. To test this, we can try running "pdc" from the command prompt. Launch the Command Prompt by pressing Windows Key and searching for "cmd"

9. Type "pdc" and press Enter in the command prompt. If you see something similar to the image, then you did it correctly!

10. Now that you can call PDC from anywhere, we just need to use it on one of our Lua projects. I am using the Drum Machine example from the Playdate SDK folder. Copy the path to the Source folder. One important thing to note is this MUST be the folder with the main.lua file in it!

11. In your Command Prompt, type "pdc" followed by the path to the folder containing "main.lua". You should also surround the path in quotation marks to prevent possible errors with the path name. The full command should look something like this:

pdc "C:\Users\username\Documents\PlaydateSDK\Examples\DrumMachine\Source"

12. If things were successful, you should see a "Source.pdx" folder in the DrumMachine folder. This is the final PDX folder than you can use on your Playdate! Feel free to rename the folder to "DrumMachine.pdx" or anything besides "Source.pdx".

13. You can either drag it directly into the Playdate Simulator, or use File -> Open to point it to the pdx folder.

Congratulations! You can now compile the Playdate Lua example projects or start working on your own Lua projects! When working on your own projects, it might get annoying to go to the command prompt, paste the text, rename the folder, and drag it to the simulator. I can write another tutorial for creating a BAT file that can automate this whole process. Hopefully this tutorial was helpful!

14 Likes

I've written template for lua projects, that contains .cmd file that automatically adds env variable:

pdc still not recognized by the command prompt... i tried installing in different locations and such but no luck :confused:

Hmm, if it's not recognized then something must have gone wrong with setting the Path to your bin folder. Make sure it's pointing to ".../PlaydateSDK/bin" and not just ".../PlaydateSDK". Also, remember that if you change your system environment variables you need to restart the command prompt or it will not register the new variables.

alas, i've double and triple checked yet pdc is still not recognized. guess i'll just keep using pulp :slightly_frowning_face:

This is what was hanging me up for the longest time. Thank you for your post... I was stuck on the Path in my bin folder.

Phrase share screenshots of your environment variables setup and paths on disk

i figured out what was wrong after a bit more troubleshooting-- thank you for reaching out!

1 Like

Just to help anyone else that comes across this tutorial through Google and can't get it to work - make sure you close all the System Environment Variable menus with the OK button before opening the command prompt, otherwise it won't work.