CPS Counter

A simple, non-functional HUD element

/*
name: Hud script
author: wallhacks
*/

var cpsList = [];

breeze.registerHud('CPSCounter', 'Shows your cps in a hud component', {
    position: new PositionSetting("Position", "The position of the CPS counter", 75, 30),

    update: function() {
        breeze.log("TEST")
        cpsList = cpsList.filter(timer => !timer.hasPassed(1000));

        // Adjust the width of the HUD based on the number of digits in the cps count
        this.position.setWidth(cpsList.length > 9 ? 85 : 75);
    },

    background: function() {
        UIRenderer.roundedRectangle(this.position.getX(), this.position.getY(), this.position.getWidth(), 30, 5, new Color(255, 255, 255, 255));
    },

    input: function(event) {
        if (event.getKeycode() === -2) { // -2 corresponds to the Left mouse button
            cpsList.push(new Timer());
        }
    },

    draw: function() {
        UIRenderer.text("CPS: ", this.position.getX() + 10, this.position.getY() + 6, new Color(255, 255, 255, 255), 20);
    },

    drawFancy: function() {
        UIRenderer.text(cpsList.length, this.position.getX() + 55, this.position.getY() + 5, new Color(255, 255, 255, 255), 22);
    }
});

Last updated