Hi,
Has anyone created a launch.json file that will run the corona simulator from VS Code? If so can you please share it or suggest how to get it working?
Thanks, Greg
Hi,
Has anyone created a launch.json file that will run the corona simulator from VS Code? If so can you please share it or suggest how to get it working?
Thanks, Greg
Hi Greg!
Here my launch.json.
{
// 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": "%CORONA_PATH%\\Corona Simulator.exe"
},
"args": [
"${workspaceFolder}",
"-no-console",
"YES",
"-debug",
"YES"
]
}
]
}
You need to install Local Lua Debugger extension.
And main.lua
if system.getInfo( "environment" ) == "simulator" then
if os.getenv("LOCAL_LUA_DEBUGGER_VSCODE") == "1" then
local lldebugger = loadfile(os.getenv("LOCAL_LUA_DEBUGGER_FILEPATH"))()
lldebugger.start()
end
end
Trace function
function Trace()
local info = debug.getinfo(3)
local file, line = string.gsub(info.source, "=", ""), info.currentline
print("Trace", "\n\tFile: " ..
file .. ":" .. line)
end
Awesome, thank you so much Kan98, I have been using zerobrane ide for a long time and am looking forward to migrating completely to VS code!
I’ve needed this for a long time, I didn’t migrate from Zerobrane to VScode precisely because of this simulator debugging problem, but how and where do I include this launch.json file in VScode? And do I have to add this verification code to all the main.lua files of projects that I create?
Just open debug tab in side menu you will see a hyper link create launch.json.
Hi Kan98,
I’ve been trying to get this working for a bit now. I installed lua-local debugger, added this to my main.lua
if system.getInfo( “environment” ) == “simulator” then
os.getenv(“LOCAL_LUA_DEBUGGER_VSCODE”) == “1” then
local lldebugger = loadfile(os.getenv(“LOCAL_LUA_DEBUGGER_FILEPATH”))()
lldebugger.start()
end
end
and in my launcher.json I’ve been playing around with different settings. It just doesn’t seem to return my full project path.
“version”: “0.2.0”,
“configurations”: [
{
“type”: “lua-local”,
“request”: “launch”,
“name”: “Debug Corona”,
“windows”: {
“program”: {
“command”: “C:\Program Files (x86)\Corona Labs\Corona\Corona Simulator.exe”,
},
“args”: [
“/no-console”,
“/debug”,
“${workspaceFolder}\main.lua”
]
},
}
]
When I run main.lua from code. I get a Solar2D message 'not found
its close…
Are you sure that path exists?
Wait me a minute, i’ll make video tutorial.
But in your case need to replace \ to \\ in command path
Awesome, thanks for the video, you made it so easy. Guess what my problem was? There was a space in my project folder name! I took it out and everything worked great. Totally VS Code now I am so excited about real debugging!!
Thanks again, Greg
Can I ask a follow up question, do you have the Outline working in the panel to the left? That’s what I am trying to get working now but it is blank.
It works fine for me.
Here are all the extensions I use.
And make sure you restarted vscode. Yeah i’m dumb. I didn’t pay attention to the note above
@jdsmedeirosbr I have a video tutorial for you, you can also install extensions like me, it is very useful for supporting Solar2D code.
Also you should remove all spaces in the project path.
Is anyone using VS Code on Mac OS? I need to try to configure the path to launch solar2d from VS debug console. I’m not sure how to reference the simulator using its path?
on a Mac default install of solar2s puts is under Applications / Corona-3722 /Corona Simulator
so the windows setting isn’t going to work, I’m not familiar enough with Apple yet to get the path right:
“command”: “%CORONA_PATH%\Corona Simulator.exe”,
Any thoughts? Thanks, Greg
“command”: “/Applications/CoronaSDK/Corona Simulator.app/Contents/MacOS/Corona Simulator”
Thank you jdsmedeirosbr, that worked! Mac OS and VS Code are working!
A quick follow up question, is it possible to have project folder names with spaces in them? The simulator won’t open with spaces in the folder name, when I rename to single word folder names it works.
Thanks again, Greg
It doesn’t work! It is not recommended to use names with spaces, if you want to separate one word from another, use underscore _
If I had £1 for every time I’ve told someone not to put spaces in filenames…
I mean, I’d probably have less than £100 but more than £10.