Skip to content
This repository has been archived by the owner on Jul 21, 2020. It is now read-only.
/ demo-heatmap Public archive

Extract TF2 player positions from an STV demo using demo.js

Notifications You must be signed in to change notification settings

laurirasanen/demo-heatmap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

demo-heatmap

Export TF2 player positions from an STV demo using demo.js.

Write positions of players to a JSON file with progress

var fs = require("fs");
var heatmap = require("demo-heatmap");

var lastProgress = 0;
var startTime = Date.now();

heatmap.getPoints(
    // Demo file name
    "example.dem",

    // Completion callback
    (err, data) => {
        if (err) throw err;

        fs.writeFile("data.json", JSON.stringify(data, null, 4), (err) => {
            if (err) throw err;

            console.log("Player data written to 'data.json'!");
        });
    },

    // Progress callback
    (current, max) => {
        // Log every 100k ticks
        if (current - lastProgress > 100000) {
            lastProgress += 100000;

            var timePassed = Date.now() - startTime;
            var speed = 1000 * current / timePassed;
            var remaining = max - current;

            console.log(`Progress: ${lastProgress}/${max}, speed: ${Math.round(speed)} ticks/s, ETA: ${Math.round(remaining / speed)}s`);
        }
    }
);

About

Extract TF2 player positions from an STV demo using demo.js

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published