This example demonstrates monitoring a directory for .slp file changes and processing them in real-time using the high-level SlippiGame API in Node.js.
- File system watching: Uses
chokidarto detect when.slpfiles are modified - Partial file reading: Reads incomplete replay files with
processOnTheFly: true - Incremental updates: Tracks game state as new data becomes available
- Live game monitoring: Displays current stocks, percentages, and frame counts
This is useful for building overlays, real-time analysis tools, or any application that needs to track live games.
- 👀 Directory watching for
.slpfile changes - 🎮 Live game state (stocks, damage, character names)
- 📊 Frame counting
- ⚡ Performance tracking (read/parse time)
- 🏁 Game end detection (TIME!, GAME!, No Contest)
-
Build the main library (from the root directory):
npm run build
-
Navigate here and install dependencies:
cd examples/realtime-file-reads npm install -
Run the script with a path to watch:
node realtimeFileReads.js /path/to/slippi/replays
Common paths:
- Slippi Desktop (Mac):
~/Documents/Slippi/ - Slippi Desktop (Windows):
Documents\Slippi\ - Custom: Check your Slippi settings for the replay directory
- Slippi Desktop (Mac):
-
Start a game and watch the console output update in real-time!
Listening at: /Users/player/Documents/Slippi/
New file at: /Users/player/Documents/Slippi/Game_20231215T120000.slp
[Game Start] New game has started
{ stageId: 31, players: [...], ... }
We have 123 frames.
Fox [Port 1] 15.3% | 4 stocks
Falco [Port 2] 42.8% | 3 stocks
Read took: 12 ms
We have 456 frames.
Fox [Port 1] 67.2% | 3 stocks
Falco [Port 2] 89.5% | 2 stocks
Read took: 15 ms
...
[Game Complete] Type: GAME!
The critical option is processOnTheFly: true when creating the SlippiGame instance:
const game = new SlippiGame(path, { processOnTheFly: true });This allows reading incomplete files and calling methods like getSettings(), getFrames(), getLatestFrame(), etc. on files that are still being written.
realtimeFileReads.js- Complete example (read this!)package.json- Dependencies
💡 Tip: Read realtimeFileReads.js to see the complete pattern. It's a standalone script showing file watching, game state tracking, and console output. The code is heavily commented with additional examples for stats tracking.