|
|
(One intermediate revision by the same user not shown) |
Line 1: |
Line 1: |
| == Visual Studio Code ==
| | Refer to [[Modding/Using Visual Studio Code#Debugging Setup]] for how to set up debugging with 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">
| |
| {
| |
| "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,
| |
| }
| |
| ]
| |
| }
| |
| </syntaxhighlight>
| |
| | |
| Make sure that the "sourceRoot" field matches your Desynced installation, it always needs to point to the top "mods" directory and not a specific mod directory inside of it. Also make sure to use forward slashes / as path separator. With the launch configuration saved, 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).
| |