Playdate get functions returning nil value (Windows VS Code)

Hello! Just getting started with Playdate dev and looking forward to making some games.

I was following a YouTube tutorial and downloaded a VS Code template.

Also set up the following environment variables in windows -

  • added C:\Users\X\Documents\PlaydateSDK\bin to path
  • added PLAYDATE_SDK_PATH as a system variable with value C:\Users\X\Documents\PlaydateSDK

I ran into some issues when writing the demo from the video, even if the code is identical which leads me to believe I may have an environment setup issue.

when writing the demo code from the video (starts around 10:45), playdate.getCrankPosition() returns a nil value, whereas the issue doesn't seem to happen in the tutorial video. I've tried other get functions and they also return nil. I tried redownloading the template, and the dvd demo provided with the template seems to run fine, however using the getCrankPostion() function still returns nil within the code there. Anything (hopefully obvious) that I may be overlooking?

demo code -

playdate console when built / ran -
14:49:31: SDK: C:\Users\shen4\Documents\PlaydateSDK
14:49:31: Release: 2.1.1
14:49:31: CMD: C:\Users\shen4\Downloads\VSCode-PlaydateTemplate-master\VSCode-PlaydateTemplate-master\builds\VSCode-PlaydateTemplate-master.pdx
14:49:31: Loading: C:\Users\shen4\Downloads\VSCode-PlaydateTemplate-master\VSCode-PlaydateTemplate-master\builds\VSCode-PlaydateTemplate-master.pdx
14:49:31: Loading: OK
Update error: main.lua:14: attempt to perform arithmetic on a nil value (local '(temp)')
stack traceback:
main.lua:14: in function main.lua:10
14:49:31: Update failed, simulator paused.

Help appreciated! I'll update here if I find the error.

EDIT : Simple syntax error on PlayerY variable name which of course devolved into a endless search of answers.

Hi, Austin! You've declared a variable PlayerY, and in the update loop, you use playerY when doing the subtraction, and PlayerY when drawing the circle. If you rename PlayerY to playerY, then it works.

1 Like

omg that's embarassing, used to having it correct me I suppose. :smiley:

Thanks!