This document is the master technical reference for rebuilding the bridge between VS Code, a Node.js v24 Server, and DCS World.
See https://github.com/jboecker/dcs-witchcraft/tree/master/src/backend for the initial version. Many thanks to jboecker for this tool which continues to be very useful.
Manually create the following structure on your E: drive (or adapt the drive letter).
E:\DCS\Edition_Missions_Tools\WitchCraft\dcs_witchcraft_V2\
βββ windows\
β βββ witchcraft.cmd <-- Server Launcher
β βββ kill_server.cmd <-- Cleanup Utility
βββ src\
βββ server.js <-- Node.js Engine (Port 3000)
βββ package.json <-- Node Configuration
βββ frontend\ <-- Web UI (index.html, console.html)
βββ common\ <-- witchcraft.js (Logic)
βββ vendor_js\ <-- socket.io.js (v4.x)
- Open a terminal in
E:\...\dcs_witchcraft_V2\src. - Run:
npm init -yfollowed bynpm install express socket.io.
Create this file to automate the bridge startup:
@echo off
TITLE DCS Witchcraft V2 Server
E:
cd /d "\DCS\Edition_Missions_Outils\WitchCraft\dcs_witchcraft_V2\src"
echo --- WITCHCRAFT V2 STARTING ---
node server.js
pauseUse this if you encounter "Port 3000 already in use" errors:
@echo off
taskkill /f /im node.exe
echo [OK] Port 3000 released.
timeout /t 2Path: C:\Users\%USERNAME%\.vscode-dcs-tools\
- Create the folder if it does not exist.
- Place your
bridge.jsfile inside. - CRITICAL: Open a terminal inside this folder and run:
npm install socket.io-client@latest
In your Lua project, create this file to enable the Shift + Ctrl + B shortcut:
{
"version": "2.0.0",
"tasks": [
{
"label": "DCS-Witchcraft: Send Lua",
"type": "shell",
"command": "node",
"args": [
"C:/Users/%USERNAME%/.vscode-dcs-tools/bridge.js",
"${file}"
],
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"reveal": "always",
"panel": "shared",
"clear": true
}
}
]
}To interact with the currently running mission by passing Lua scripts to it on the fly, open the Witchcraft console in a browser using the URL: http://localhost:3000/console.html This console allows you to open multiple snippets, making it easy to run several scripts in parallel.
Each snippet has a return terminal to display the data returned by DCS. Thus, visualizing a DCS object is possible via a simple return statement (e.g., return Unit.getByName("groundUnit-1") returns the table for the object named groundUnit-1).
File: C:\Program Files\Eagle Dynamics\DCS World\Scripts\MissionScripting.lua
- Comment out the
io,os, andlfslines by adding--at the start. - Append this specific block to the end of the file:
------------- Witchcraft Debugging System ----------------------
witchcraft = {}
witchcraft.host = "localhost"
witchcraft.port = 3001
dofile(lfs.writedir().."Scripts\\Witchcraft.lua")- Place the original
Witchcraft.luain%USERPROFILE%\Saved Games\DCS\Scripts\. - Place the original
WitchcraftExport.luain%USERPROFILE%\Saved Games\DCS\Scripts\. ordofile(lfs.writedir()..[[Scripts\Witchcraft.lua]])in Export.lua ordofile(lfs.writedir()..[[Scripts\WitchcraftExport.lua]])in Export.lua
To allow the mission environment to accept incoming commands, you must open the socket via a trigger within the Mission Editor.
- Trigger:
ONCE(ONE TIME). - Condition:
TIME MORE (1). - Action:
EXECUTE SCRIPT:
dofile("%USERPROFILE%\\Saved Games\\DCS\\Scripts\\Witchcraft.lua")| Segment | Protocol | Port |
|---|---|---|
| VS Code -> Node Server | Socket.io (Websocket) | 3000 |
| Web Console -> Node Server | HTTP / Websocket | 3000 |
| Node Server -> DCS Mission | TCP (RAW JSON) | 3002 |
- Cleanup: Run
kill_server.cmd(Optional, only if ports are locked). - Server: Run
witchcraft.cmd. Keep this window open. - DCS: Start your mission. The server console must display
[Witchcraft] Connection established. - Edit: Modify your Lua file in VS Code stay on lua file you want to execute and press Shift + Ctrl + B.
- Confirm: The VS Code terminal will display
[SUCCESS] DCS acknowledged execution.
Technical Note: You must re-apply Step 4.A after every DCS World update, as the installer frequently overwrites the
MissionScripting.luafile.