__stub.lua missing various methods

Caveat: I am new to Lua and Playdate

I am using VSCode to edit Lua, and am trying to avoid Lua Diagnostic warnings.
It appears that VSCode depends on PlaydateSDK/CoreLibs/__stub.lua.
I believe that this uses the Lua LSP.
In my code so far, I have warnings about the following undefined fields:

  • playdate.graphics.image.new
  • playdate.graphics.kColorWhite
  • playdate.graphics.kDrawModeNXOR
  • playdate.geometry.point.new
  • playdate.graphics.sprite.new

These are all valid and documented.
I think that the solution is to add them to __stub.lua.

1 Like

Thanks for the report, we do have an open ticket on adding these constants and missing functions. Thanks again.

Is there a resolution for this one?
I'm getting this with the basic tutorial in the Playdate documentation and am unable to get anything running.

These missing stubs won't affect getting things running.

Your screenshot doesn't show all of the code in the example? And of course you'll need to provide your own images for that one.

Hi Matt
I've attached the complete code. The console is giving me:
main.lua 12: assertion failed
Hopefully, you're able to point me in the right direction!

Assertion at line 12 basically says "don't go any further if theres nothing in playerImage"

Did you put an image file like a PNG at that location?

It's unrelated to the tooltip thing.

Another, related issue I've found is that the stub file has function playdate.file.readLine() end. This meant that I got an autocomplete for readLine, but it should be readline (lowercase).

Hi Matt
There was an image at the location but when I tried a different image it worked. I can only assume the original PNG was corrupted or something!
Anyway, thanks for the direction. It's going to be a while before I release anything if the tooltips are causing me a headache :smiley: :smiley:

1 Like

As of 2.2.0 the methods mentioned in the OP are now in __stub.lua, but the table methods from Inside Playdate are not. Please could these be added, too?

Thanks, this should be fixed in the next release.