# FlyWithLua companion — FMS two-way sync X-Plane's Web API can't write a flight plan into the FMS. `fms-sync.lua` runs inside X-Plane (via FlyWithLua, which has the FMS SDK) and syncs the shared cockpit plan ↔ the in-sim FMS through two files in `Output/fms-sync/`. ## Install (sim PC only) 1. Install **FlyWithLua NG+** (free): copy its plugin folder into `/Resources/plugins/FlyWithLua/`. 2. Start the bridge (desktop app or `node server/bridge.js`) **on the same PC** as X-Plane. On startup it auto-copies these three scripts into `/Resources/plugins/FlyWithLua/Scripts/` and keeps them up to date on every launch (it only writes changed/missing files): - **`fms-sync.lua`** — flight-plan two-way sync - **`ui-sync.lua`** — G1000 UI state (page / range / inset) - **`terrain-probe.lua`** — terrain-awareness elevation grid for the MFD 3. In X-Plane: *FlyWithLua → Reload all Lua script files* (or restart). The log shows `[glass-cockpit] FMS sync active`. No manual copying needed. If you install FlyWithLua *after* the bridge is already running, trigger a re-install without restarting via `POST /api/lua/install`. The current install state is reported under `lua` in `GET /api/health`. The bridge must run on the **same PC** as X-Plane so both see `/Output/fms-sync/`. (The auto-install honours `LUA_SRC_DIR` — the desktop app sets it to the bundled scripts; otherwise it finds `plugins/` itself.) ## What you get - **App → Sim:** load/build a plan in the web cockpit → it appears in the 3-D G1000 and the autopilot can fly it. - **Sim → App:** build/edit the plan in the real FMS → it shows on every tablet. - **Terrain:** the MFD TERRAIN map colours real scenery elevation red/yellow relative to your altitude (probed live by `terrain-probe.lua`). A 3-decimal lat/lon signature de-dupes the round-trip, so the two sides never loop. Waypoints are pushed as lat/lon legs (exact route; in-sim idents are generic — route accuracy over cosmetics). ## Cessna Citation X (Honeywell Primus 2000) The app ships three switchable **cockpit profiles** (sidebar dropdown): the Garmin **G1000**, the **Citation X**, and a **GA steam** panel. The Citation profile recreates the Primus 2000 suite line-for-line from the X-Plane Citation X manual — **PFD** (attitude, speed/alt tapes with Vmo barber-pole + Vfe + AOA, HSI with VOR/ADF bearing pointers, CDI, VSI, FD bars, radar altimeter, minimums), **MFD** (Honeywell arc map, FMS route, TCAS, terrain/WX, ETE/SAT/TAS/ GSPD, ET/FT timer, V-SPEEDS card), **EICAS** (twin N1/ITT/oil, fuel, electrical, hydraulics, slats, stab-trim, flaps, CAS), the **autopilot/flight-guidance** controller (HDG/NAV/APP/BC · ALT/VNAV/BANK/STBY · FLC/VS · AP/YD/M-TRIM/PFD-SEL + pitch wheel), the **Radio Management Unit**, and the **Nav Source Selector**. Integration: - **Avionics (PFD/MFD/EICAS/AP/RMU):** every value is a universal X-Plane dataref / command streamed live by the bridge over the **Web API** — no Lua needed (N1/N2/ITT, radar-alt, AOA, hydraulics, trim, flaps/slats/gear, control positions, ADF, mach, yaw-damper, the per-mode `*_status` AFCS annunciation…). - **FMS / CDU:** the same **`fms-sync.lua`** bridges the web CDU ↔ the in-sim FMS. It uses the aircraft-agnostic XPLM FMS SDK, so it drives the Citation X's built-in FMS exactly as it does the G1000's — load/build a plan on a tablet and the Citation flies it; build it in the sim and it shows on every tablet.