Defold Kit — Visual Studio Code Extension

Thanks for your help and your time !
I can find a way to build form Bob with:

Defold/packages/jdk-21.0.5+11/bin/java -cp Defold/packages/defold-83536c65275c04366b704b2fd3f3d681c88b8267.jar "com.dynamo.bob.Bob" --variant debug --output build/defoldkit build

It works fine: 100% ...done!

Then I need to make linux dmengine executable, and copy it inside build/defoldkit

chmod +x build/x86_64-linux/dmengine
cp build/x86_64-linux/dmengine build/defoldkit/
build/defoldkit/dmengine

And… TADA ! It works !
How I can achieve this from your extension ?

This is what extension do. At least it’s expected :grinning_face_with_smiling_eyes: .

Could you take a look at logs please? Select the Output tab and Defold Kit to check what’s the difference between your manual scenario and the automated one by the extension?

I believe I have identified the issue. While debugging in VSCodium still results in the same error, the code executes successfully when run directly from another terminal within the Defold project or from the build folder. However, running the code from the VSCodium terminal produces the same error.

The problem appears to be related to the Flatpak version of VSCodium (the same issue occurs with the Flatpak version of Visual Studio Code). The sandboxing system used by Flatpak seems to prevent access to certain environment variables, libraries, or paths outside of the sandbox. This restriction is likely causing the libGLU.so.1 library to be unavailable, resulting in the error.

1 Like

Workaround for flatpak version of VSCodium:

In project: .vscode/launch.json, modify:

  • key "command" to:
"program": {
   "command": "/app/bin/host-spawn",
},
  • key "args" to:
 "args": [
   "build/defoldkit/dmengine",
   "build/defoldkit/game.projectc"
],

Example: launch.json

{
    "configurations": [
        {
            "name": "Defold Kit",
            "type": "lua-local",
            "request": "launch",
            "stopOnEntry": false,
            "verbose": false,
            "internalConsoleOptions": "openOnSessionStart",
            "program": {
                "command": "/app/bin/host-spawn",
            },
            "args": [
                "build/defoldkit/dmengine",
                "build/defoldkit/game.projectc"
            ],
            "windows": {
                "program": {
                    "command": "build\\defoldkit\\dmengine.exe"
                },
                "args": [
                    "build\\defoldkit\\game.projectc"
                ]
            },
            "preLaunchTask": "Defold Kit: Build to Launch"
        }
    ]
}
2 Likes

Hello, I have just started experimenting with VS Code and Defold Kit extension.

However, I have a problem. When I run debug session with a breakpoint, it stops on it properly but later on, if I untoggle it (the breakpoint), resume execution, and toggle back, the program doesn’t stop on it anymore. Is this normal behavior? I have added the debugger.script to my main collection.

Hello,

There is some limitation of Lua Local Debugger extension. It updates breakpoints only during pauses, not at the runtime. The issue has already been resolved, but hasn’t merged in 3 years, don’t know why.

Two workarounds:

  1. Call debugger.requestBreak() by some way in your game to request a pause to update all the breakpoint on that moment. For example, by pressing the ‘D’ key.
  2. Try to find and use a fork of Lua Local Debugger where the PR is merged (this one?)
2 Likes

Thank you for the answer. I added a key binding to break the debugger and can toggle the breakpoints to my heart’s content during that pause.

I have just found that my question has been answered in the docs of the extension, pardon! :sweat_smile:

1 Like

Hi, amazing extension, could you check this:

Hi @Dreamer_Android,

Spine is an external extension that adds functions to the gui namespace. Since it is an external extension, that’s not correct to include its annotations in the annotations releases because it should be avaulable only when the external extension is added to the project.

I see two ways to have annotations for external extensions:

  1. Add lua annotations to the repo of the extension (PR / maintaining). This is a manual way without any perspectives to cover all the existing extensions, but it works out of box.

  2. Start to parse *.script_api files.

Parsing *.script_api` files

On the one hand, this is better to do in astrochili/defold-annotations, since all annotation generation is already there. But it is not clear how to run this script in the VSCode extension on the fly, without having to run the Lua runtime.

On the other hand, for the solution to be included in the Defold Kit, it’s better to write it in TypeScript. But then there would be another parser / annotation generator, which is not very optimal…

I don’t know yet which solution is optimal and how the Defold Editor solves this prioblem (script_api + lua language server) for itself.

1 Like

Hi there,

First off, thanks so much for this extension—really appreciate it!

I have a quick question: Is it possible to configure the debugger so I can step into library code?

For example, I’m using the Druid framework, and when I try to step into a library function, the debugger only shows the filename and line number but not the actual code.

I know this works when debugging in the Defold editor, so I’m wondering if there’s a setting I need to adjust in VS Code to get the same behavior.

Any help would be greatly appreciated!

Thanks!

Hi!

Theoretically it should work if you add the workspace storage path from the .vscode/settings.json file (e.g. ...workspaceStorage/.../astronachos.defold/) to the Local Lua Debugger launch configuration file .vscode/launch.json.

Look at scriptFiles and scriptRoots for details and examples.

UPDATE:
It works! But the path should be full, without any shortcuts like ~. A tilde doesn’t work here.

Awesome, that did the trick! Debugging is so much easier now:)

Thanks a ton!

1 Like