-
Notifications
You must be signed in to change notification settings - Fork 378
Setting Up Visual Studio Code
This guide was written based on an installation with Ubuntu 24.04 inside WSL2, but it should work the same on any ordinary Linux installation.
You should clone and configure the build of CorsixTH as per the Linux compilation instructions tells you. (or you can use the C/C++ extension of VSCode which autodetects the CMakePresets.json, choose linux-dev as preset when asked)
- Install the Lua extension to VSCode: https://marketplace.visualstudio.com/items?itemName=sumneko.lua
- Install the Lua MobDebug adapter extension in VSCode: https://marketplace.visualstudio.com/items?itemName=AlexeyMelnichuk.lua-mobdebug
- Install Lua 5.3 interpreter (or what version the actual CorsixTH Linux compilation guide recommends for
liblua):sudo apt install lua5.3 - Install luarocks via it's guide: https://luarocks.org/#quick-start
- Install luasocket with luarocks:
sudo luarocks install luasocket
-
Open
CorisxTH/CorisxTH.luaand add the following on top of the file (change the path where your VSCode extension folder resides, in this example I'm using the remote VSCode server's extension path):package.path = '/home/user/.vscode-server/extensions/alexeymelnichuk.lua-mobdebug-0.0.5/lua/?.lua' .. ';' .. package.path require('mobdebug').start() -
Open
CorsixTH/Lua/app.luaand findApp:run()function, insert the following to the coroutine function's body as the first line:require('mobdebug').on()
-
Switch to the Run & Debug tab in VSCode and create a new "Lua MobDebug: Listen" type debug configuration.
In thelaunch.jsonfile replace the autogenerated block with the following (don't forget to edit your executable path where the compiledcorsix-thexecutable resides):{ "name": "Lua MobDebug: CorsixTH", "type": "luaMobDebug", "request": "attach", "workingDirectory": "${workspaceFolder}", "sourceBasePath": "${workspaceFolder}", "listenPublicly": false, "listenPort": 8172, "stopOnEntry": false, "sourceEncoding": "UTF-8", "executable": "${workspaceFolder}/build/dev/CorsixTH/corsix-th" } -
Test your setup, place a breakpoint into
CorsixTH/Lua/room.luaatRoom:initRoom(). Launch the debug configurationLua MobDebug: CorsixTHfrom VSCode's menu. Begin a game and try to place a room. Once you try to move to next step from the blueprint, the game should stop and VSCode will jump to the breakpoint and show the stacktrace.