Jamjardavies (talk | contribs) No edit summary |
(Update debugging information) |
||
Line 1: | Line 1: | ||
== Visual Studio Code == | == Visual Studio Code == | ||
In order to debug using Visual Studio code, | In order to debug using Visual Studio code, you need to install the lrdb-beamng extension: https://marketplace.visualstudio.com/items?itemName=beamng.lrdb-beamng | ||
With the extension installed, make sure to start the game with <code>-moddev</code> and keep it running. | |||
To attach the debugger, switch to the 'Run and Debug' tab in Visual Studio Code (menu 'View' -> 'Run' or by pressing <code>CTRL + SHIFT + D</code>). Click on the "create a launch.json" link and replace the content with the following: | |||
<syntaxhighlight lang="js" line="1"> | <syntaxhighlight lang="js" line="1"> | ||
Line 20: | Line 11: | ||
"configurations": [ | "configurations": [ | ||
{ | { | ||
"type": "lrdb", | |||
"type": " | |||
"request": "attach", | "request": "attach", | ||
" | "name": "Attach", | ||
" | "host": "localhost", | ||
" | "port": 21110, | ||
" | "sourceRoot": "C:/Program Files (x86)/Steam/steamapps/common/Desynced/Desynced/Content/mods", | ||
" | "stopOnEntry": false, | ||
} | } | ||
] | ] | ||
Line 33: | Line 23: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Make sure that the "sourceRoot" field matches your Desynced installation then press F5 to attach the debugger to the game. If it doesn't end up connecting, open the "LUA REMOTE DEBUGGER - VMS" panel in the 'Run and Debug' tab of Visual Studio Code and try to double click the Desynced Lua VM which should be shown running on "localhost:21110". | |||
Once connected, you'll have full access to breakpoints, code stepping, as well as accessing local and global variables and the watch window. Also it is recommended to open the Debug Console (menu 'View' -> 'Debug Console' or by pressing <code>CTRL + SHIFT + Y</code>) to have any logging or errors appear directly in Visual Studio Code. The debug console is interactive, too, so entering code into the input text box below the console will execute it in the game. This can be used to execute <code>Debug.Reload()</code> which will hot reload the Lua code from inside the code editor (same as pressing F7 in the game). |
Revision as of 14:12, 11 April 2024
Visual Studio Code
In order to debug using Visual Studio code, you need to install the lrdb-beamng extension: https://marketplace.visualstudio.com/items?itemName=beamng.lrdb-beamng
With the extension installed, make sure to start the game with -moddev
and keep it running.
To attach the debugger, switch to the 'Run and Debug' tab in Visual Studio Code (menu 'View' -> 'Run' or by pressing CTRL + SHIFT + D
). Click on the "create a launch.json" link and replace the content with the following:
{
"version": "0.2.0",
"configurations": [
{
"type": "lrdb",
"request": "attach",
"name": "Attach",
"host": "localhost",
"port": 21110,
"sourceRoot": "C:/Program Files (x86)/Steam/steamapps/common/Desynced/Desynced/Content/mods",
"stopOnEntry": false,
}
]
}
Make sure that the "sourceRoot" field matches your Desynced installation then press F5 to attach the debugger to the game. If it doesn't end up connecting, open the "LUA REMOTE DEBUGGER - VMS" panel in the 'Run and Debug' tab of Visual Studio Code and try to double click the Desynced Lua VM which should be shown running on "localhost:21110".
Once connected, you'll have full access to breakpoints, code stepping, as well as accessing local and global variables and the watch window. Also it is recommended to open the Debug Console (menu 'View' -> 'Debug Console' or by pressing CTRL + SHIFT + Y
) to have any logging or errors appear directly in Visual Studio Code. The debug console is interactive, too, so entering code into the input text box below the console will execute it in the game. This can be used to execute Debug.Reload()
which will hot reload the Lua code from inside the code editor (same as pressing F7 in the game).