-
Install VSCode
-
Install tangzx.emmylua extension (debugging and stubs)
-
Install omltcat.dcs-lua-runner extension (inject code at runtime)
-
Install dcs-fiddle-server.lua into
Saved Games/DCS/Scripts/Hooksfolder (required for lua runner) -
Create a launch.json debug config (emmylua debugger setup)
For mission and gui environments, just send the code (snippet) to the DCS LUA Runner extension (^k ^s to setup hotkey).
-
Run following code snippet in the env you want to debug (by either injecting, or insert in any script)
package.cpath = package.cpath .. ';C:/Users/USERNAME/.vscode/extensions/tangzx.emmylua-0.8.18-win32-x64/debugger/emmy/windows/x64/?.dll' local dbg = require('emmy_core') dbg.tcpConnect('localhost', 9966) end)
-
Desanitize
DCS World/Scripts/MissionScripting.luato enable mission scripting debugging and fiddle server (for DCS LUA Runner)sanitizeModule('os') sanitizeModule('io') sanitizeModule('lfs') -- _G['require'] = nil _G['loadlib'] = nil -- _G['package'] = nil
-
Start the VSCode debug config
-
Start DCS
Create .emmyrc.json in root directory of your project, and set path to stubs in workspace library, see .emmyrc.json
-
Hooks are loaded only once on game/server start, so you need a restart on change, when debugging hooks
-
While working in the ME, scripts are in a temporary folder, so the debugger can't match the file path
-
You can workaround in both cases by using
dofile('/path/to/script.lua')(either within a hook callback, or within a "DO SCRIPT" action) to force correct path -
To debug other scripts besides mission script, put the debug snippet in the any file (Export.lua, entry.lua, ...) where package/require is available
Install https://www.msys2.org/
Add to VSCode terminals:
"terminal.integrated.profiles.windows": {
"MINGW64": {
"path": "C:\\Dev\\msys64\\usr\\bin\\bash.exe",
"args": ["--login", "-i"],
"env": {
"MSYSTEM": "MINGW64",
"CHERE_INVOKING": "1"
}
}
}Add to Windows Terminal:
{
"guid": "{a0a1a2a3-a4a5-a6a7-a8a9-aaabacadaeaf}",
"name": "MSYS2 MinGW64",
"commandline": "C:\\Dev\\msys64\\usr\\bin\\bash.exe -l -c \"/mingw64.sh\"",
"startingDirectory": "%USERPROFILE%",
"icon": "C:\\Dev\\msys64\\msys2.exe"
}Start script ming64.sh (in C:/Dev/msys64)
#!/usr/bin/env bash
export MSYSTEM=MINGW64
export CHERE_INVOKING=1
exec /usr/bin/bash -lUseful commands:
-
Find files with "pilot" and "edm" in name
find /e/Games/DCS\ World -iname "*pilot*edm"
-
Log file realtime viewing with filter
tail -f /c/Users/user/Saved\ Games/DCS/Logs/dcs.log | grep -i a4e
-
Update mingw64
pacman -Syu
-
Some packages
pacman -S mingw-w64-x86_64-neovim pacman -S tmux pacman -S git pacman -S python pacman -S python-pip