mirror of
https://github.com/demostf/demo.js
synced 2026-06-03 16:44:12 +02:00
readme
This commit is contained in:
parent
7692aa61c9
commit
d4716edca1
1 changed files with 35 additions and 1 deletions
36
README.md
36
README.md
|
|
@ -23,10 +23,34 @@ fs.readFile("example.dem", function (err, data) {
|
|||
var head = parser.readHeader();
|
||||
console.log(head);
|
||||
var body = parser.parseBody();
|
||||
console.log(body);
|
||||
console.log(body.getState());
|
||||
});
|
||||
```
|
||||
|
||||
### more information from packets
|
||||
|
||||
Using the javascript api it's possible to get far more information out of a demo
|
||||
file than the basic state provided by the cli interface.
|
||||
|
||||
```js
|
||||
var Demo = require('tf2-demo');
|
||||
var fs = require('fs');
|
||||
|
||||
fs.readFile("example.dem", function (err, data) {
|
||||
if (err) throw err;
|
||||
var demo = Demo.fromNodeBuffer(data);
|
||||
var parser = demo.getParser();
|
||||
var head = parser.readHeader();
|
||||
var match = parser.match;
|
||||
parser.on('packet', function(packet) {
|
||||
// where you can either get information directly from the packet (see ./src/Data/Packet.ts)
|
||||
// or use the `match` object which has contains an (incomplete) state of the match at the current tick
|
||||
});
|
||||
parser.parseBody();
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
## A note on POV demos
|
||||
|
||||
During the development of this project the main focus has always been on parsing
|
||||
|
|
@ -36,3 +60,13 @@ STV demos. Parsing POV demos is a lot more error prone and has known issues.
|
|||
|
||||
- Not all player names can be parsed correctly, resulting in multiple players
|
||||
having `null` as a name in the output.
|
||||
|
||||
## Credits
|
||||
|
||||
Special thanks goes to
|
||||
|
||||
- Panzer for [DemoLib](https://github.com/PazerOP/DemoLib)
|
||||
- The StatsHelix team for [DemoInfo](https://github.com/StatsHelix/demoinfo)
|
||||
- The SkadiStats for [smoke](https://github.com/skadistats/smoke)
|
||||
|
||||
Without the information provided by these projects this would not have been possible
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue