@vinceau/slp-realtime v3.1.0-beta.2
slp-realtime
The brains and the brawn of Project Clippi.
This library provides an easy way to subscribe to real-time Slippi game events as they happen. Rebuilt from the ground up using RxJS Observables, the power to subscribe to any and every event is in your hands.
Highlights
- Go file-less. Read directly from the relay or console.
- Custom combos. Easily add combo parameters and output Dolphin-compatible JSON files.
- Powerful RxJS Observable and Stream API.
Installation
This package relies on the rxjs package as a peer dependency and must be installed alongside.
With NPM
npm install @vinceau/slp-realtime rxjsWith Yarn
yarn add @vinceau/slp-realtime rxjsUsage
For a list of all the subscribable events, click here.
See a working example or check out the docs.
The following usage examples use the more complex RxJS Observable API. For a more simplified usage, check out the JSON Config API and the accompanying working example.
Subscribing to In-Game Events
We can use this library to subscribe to in game events.
First instantiate an instance of SlpLiveStream and connect to a Wii or Slippi relay.
const { SlpLiveStream } = require("@vinceau/slp-realtime");
const livestream = new SlpLiveStream();
livestream
.start(address, slpPort)
.then(() => {
console.log("Successfully connected!");
})
.catch(console.error);Then instantiate an instance of SlpRealTime and pass the SlpLiveStream to it.
We will use it to subscribe to desired events. For example:
const { SlpRealTime } = require("@vinceau/slp-realtime");
const realtime = new SlpRealTime();
// Read from the SlpLiveStream object from before
realtime.setStream(livestream);
realtime.game.start$.subscribe(() => {
console.log("game started");
});
realtime.stock.playerSpawn$.subscribe((stock) => {
const { playerIndex, count } = stock;
console.log(`player ${playerIndex + 1} spawned with ${count} stocks remaining`);
});
realtime.combo.end$.subscribe(() => {
console.log("wombo combooo!!");
});Detecting Custom Combos
We can subscribe to the end of any and every combo but really what we want is to filter for specific combos.
First, instantiate a ComboFilter. For all the possible filtering options, see ComboFilterSettings.
const { ComboFilter } = require("@vinceau/slp-realtime");
const comboFilter = new ComboFilter();
comboFilter.updateSettings({
excludeCPUs: false, // combos on CPUs are okay
comboMustKill: false, // combos don't have to kill
minComboPercent: 40, // combos have to do at least 40% damage
});ComboFilter has an isCombo() method which returns true if a given combo matches the specified criteria. We can hook it up to our live stream with the following:
realtime.combo.end$.subscribe((payload) => {
const { combo, settings } = payload;
if (comboFilter.isCombo(combo, settings)) {
console.log("Combo matched!");
}
});Make a Custom HUD
Want to make your own HUD?
- Subscribe to percent and stock changes
- Write the data to a file
- Add files to OBS
- ???
- Profit!!
realtime.stock.percentChange$.subscribe(payload => {
const player = payload.playerIndex + 1;
console.log(`player ${player} percent: ${payload.percent}`);
fs.writeFileSync(`./player${player}Percent.txt`), payload.percent);
});
realtime.stock.countChange$.subscribe((payload) => {
const player = payload.playerIndex + 1;
console.log(`player ${player} stocks: ${payload.stocksRemaining}`);
fs.writeFileSync(`./player${player}Stocks.txt`), payload.stocksRemaining);
});Development
To build the library from source:
yarn run buildTo start the development server:
yarn run watchTo run the tests:
yarn run testAcknowledgements
This project was made possible by:
Jas Laferriere and the rest of the Project Slippi team
NikhilNarayana and his Get Slippi Combos script
License
This software is released under the terms of MIT license.
Linking back to this Github repo is much appreciated.
2 years ago
2 years ago
3 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
