tomblind / local-lua-debugger-vscode

Local Lua Debugger for VSCode
MIT License
107 stars 26 forks source link

Corona SDK config setup #7

Closed wickeym closed 3 years ago

wickeym commented 5 years ago

I created a launch environment for Corona SDK, but the one issue I ran into is that it doesn't automatically find lldebugger when I do require("lldebugger").start(). What I ended up doing was copying in the lldebugger.lua file from inside the extension. Is this because it was launched from Corona SDK?

For anyone wanting to debug Corona SDK:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "lua-local",
            "request": "launch",
            "name": "Debug Corona",
            "program": {
                "command": "/Applications/Corona/CoronaSimulator.app/Contents/MacOS/CoronaSimulator"
            },
            "args": [
                "-no-console YES -debug 1 -project ${workspaceFolder}/main.lua"
            ]
        }
    ]
}

Also I removed the spaces from the path and created a copy there. Do you know how to use spaces in the path?

Thanks for the great extension! :)

Sincerely, Michael Wickey

tomblind commented 5 years ago

I've used the debugger with Corona on Windows without needing to copy the file. I wonder if environment variables aren't being passed correctly in OSX. Between this and #5 I'll need to find a Mac to do some testing on πŸ˜„

wickeym commented 5 years ago

I can also look into it sometime, and/or also can test it on my Mac anytime.

Thanks for the quick response.

tomblind commented 5 years ago

For a quick test, can you see what the value of os.getenv("LUA_PATH") is when running the project in the simulator?

wickeym commented 5 years ago

/Users/wickeym/Library/Application Support/Corona/Simulator/Plugins/?.lua;/Users/wickeym/Documents/WW-GIT/ifplus-hashtags/?.lua;/Applications/Corona/CoronaSimulator.app/Contents/Resources/?.lua;

tomblind commented 5 years ago

Hmm, yes, it looks like the modification to the environment variable isn't making it through.

BTW - an alternative to moving the file is adding the path to lldebugger.lua to package.path in lua:

package.path = package.path .. ";path/to/debugger/script/?.lua"
require("lldebugger").start()

Still hacky, though πŸ˜„

wickeym commented 5 years ago

Ah good idea, I'll do that for now! πŸ‘

tomblind commented 4 years ago

@wickeym Has this been resolved, or do you still need the workaround?

wickeym commented 4 years ago

Ah no, I closed it prematurely. I forgot the original issue was that it didn't find the lldebugger.lua and not the spaces in file path.

tomblind commented 4 years ago

Ok - good to know. I do plan to grab a macbook from someone at some point to figure this and other OSX-related bugs.

wickeym commented 3 years ago

Hi Tom,

This issue is now resolved ever since you added the tip to load the extension file from an environment variable.

The code I have at the top of my Solar2D (formerly Corona) SDK:

if os.getenv("LOCAL_LUA_DEBUGGER_VSCODE") == "1" then
    package.loaded["lldebugger"] = assert(loadfile(os.getenv("LOCAL_LUA_DEBUGGER_FILEPATH")))()
    require("lldebugger").start()
end

And this is my launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "lua-local",
            "request": "launch",
            "name": "Debug Corona",
            "program": {
                "command": "/Applications/Corona/Corona Simulator.app/Contents/MacOS/Corona Simulator"
            },
            "args": [
                "-no-console YES -debug 1 -project ${workspaceFolder}/main.lua"
            ]
        }
    ]
}

Please feel free to use my code in the Readme for Solar2D integration.

Thank you for an awesome debugger!

Sincerely, Michael Wickey