Compilation errors with ZeroBrane Studio (Lua IDE) and Visual Studio Code

Hello! This is my first dev forum post! Glad to be here.

My programming experience is mostly Adventure Game Studio, so I gravitated towards using ZeroBrane Studio, a Lua IDE. I got stuck pretty early going through the Inside Playdate documentation, though.

I pasted the "3. A Basic Playdate Game in Lua" code into ZeroBrane but I got a compilation error (see attached image). This is with PlaydateSDK-0.11.0-98931_2218b0e.

Judging from this post (regarding a similar issue) by @nick_splendorr (Is there a Lua 5.4 Syntax extension for VS Code? - #3 by nick_splendorr) with VS Code regarding local <const> and += and -= Playdate convenience features, this may be a common stumbling block. What can be done about this? Nick brings up "modifying a syntax highlighter" as a solution, but that sounds way beyond my capabilities.

A possible solution could be to updating ZeroBrane to Lua 5.4, but I don't know how to do that (its current is version 5.3). I've tried, but my knowledge is very limited. I tried following these instructions but couldn't make it work. But come to think of it, if the syntax errors are Playdate convenience features -- Maybe that wouldn't help anyway.

I'm crossing my fingers for a relatively easy to implement solution! It's very, very possible I missed an important step in all of this -- My heart hopes so, but my ego doesn't! :stuck_out_tongue:

1 Like

Welcome! :clap: Love your adventure game work and loved your Photoshop "realisation" video. :pray:

I think the easiest solution here is to see downgrade the code to syntax that is suitable for your IDE.

So simply remove all <const> (a Lua 5.4 thing; they're not strictly needed but help Lua run your code more optimally) and expand x += y to x = x + y (a Playdate SDK thing; not part of Lua) and so on.

See how that goes?

1 Like

I still have no solution for the -= and += highlighting, but the <const> highlighting, undefined globals, and lowercase globals can be taken care of pretty simply with settings.json in your .vscode folder of your project directory. This is what mine looks like:

{
  "Lua.runtime.version": "Lua 5.4",
  "Lua.diagnostics.disable": ["undefined-global", "lowercase-global"],
  "Lua.diagnostics.globals": ["playdate", "import"],
  "Lua.workspace.library": {
    "<sdk path>\\CoreLibs": true
  }
}

I followed the instructions inside the Playdate extension for VSCode to get code completion working.

1 Like

Welcome, Julia! The best I can recommend is that you avoid Lua 5.4 and Playdate convenience features. As @matt said, doesn't seem to be a huge deal for performance, and += / -= (while convenient, not really that much shorter than a = a + 1).

The only editor I know of that handles all of this is Panic's Nova, which is Mac-only, and may come up short in other features depending on your needs, since it's new and doesn't have a fully-developed extension ecosystem yet.

@ast-rsk, those VS Code settings tips are great! I haven't made any progress toward actually implementing those features in VS Code! Outside my experience, too. But I've gotten by perfectly fine without <const> and +=!

1 Like

Hello, folks! Thanks for your kind words and thanks so much for the tips n' tricks! I've replaced all the <const> stuff in the example game and that bit works fine now. Hooray!

I've being trying the Playdate extension for VSCode and following the instructions as best I can, but I'm stuck on a couple things. I have Microsoft VS Code and the Playdate SDK in my workspace, but getting the warning "Property source is not allowed" for launch.json. For these two lines: "source": "${workspaceFolder}/Source", "output": "${workspaceFolder}/Output",. I didn't think I needed to edit those lines, but do I?

Second issue is when I try to copy and paste the example game from "3. A Basic Playdate Game in Lua" in the Inside Playdate documentation: Undefined global import. I've tried specifying the path for the import (Copy Path / Copy Relative Path) but those don't work either. I get the same issue in ZeroBrane (a Lua IDE): attempt to call global 'import' (a nil value). Is there something I need to define elsewhere?