MV Commas in damage number pop-ups in combat?

I was wondering if there is any plugin out there that is available or could be made for RPG Maker MV that enables damage pop-up numbers in combat to have commas (,) placed for numbers 4 digits and up. I am aware for these numbers the game reads the damage.png in the img folder, so I figured a plugin would be the best solution as it would need to change how to game reads the file or where it grabs the comma from.

Screenshot 2024-05-26 130044.png

The image above shows how the numbers in my game are displayed as of now. (Its in a custom font but that is besides the point). I would like 1426944769 to instead read out as 1,426,944,769 in the pop-up. Some other examples would be:
1444 -> 1,444
15250 -> 15,250
202404 -> 202,404
ect.

Again using RPG maker MV, and im using the default battle system with the Yanfly battle engine core if that counts for anything. If I need to provide any other info let me know.
Paste the below into a text editor, save as a *.js file, include as a plugin.

Code:
Sprite_Damage.prototype.createDigits = function(baseRow, value) {
    var string = Math.abs(value).toLocaleString();
    var row = baseRow + (value < 0 ? 1 : 0);
    var w = this.digitWidth();
    var h = this.digitHeight();
    for (var i = 0; i < string.length; i++) {
        var sprite = this.createChildSprite();
        var n = string[i] == ',' ? 10 : Number(string[i]);
        sprite.setFrame(n * w, row * h, w, h);
        sprite.x = (i - (string.length - 1) / 2) * w;
        sprite.dy = -i;
    }
};

That should work correctly if you add commas to the right of the numbers in the Damage.png.
Haya! Thanks so much for the plugin, need a bit of help. I'm a bit confused as to where to put the commas on the Damage.png,
Damage.png


This is the Damage.png, at its default 240x160 size. I have attempted to make a 24 pixel extension to the right, line up a comma on each row next to the 9s at the end, but it only seems to jumble and cut off the numbers in the damage pop up when I try. I don't think it likes me messing with the canvas size, because testing it without commas it seems to just space out where the commas would go, so I think this is disconnect on my end here :ptea: sorry.

Where exactly should I be inserting my commas, is it next to each digit, or just after the 9s? I may in the end here just need to resize my numbers if that's the case, or better yet, where exactly on the png is it reading to grab said comma, if I know exactly where on the sheet it grabs it i'll know how to fit it in. Thank you again, very much appreciate your hard work and time!
Ah, I see. The digit width needs to be recalculated. Add this to the plugin:
Code:
Sprite_Damage.prototype.digitWidth = function() {
    return this._damageBitmap ? this._damageBitmap.width / 11 : 0;
};
Works perfect! Thank you very much!
Screenshot 2024-05-31 131132.png

Screenshot 2024-05-31 131233.png

Screenshot 2024-05-31 131344.png

Numbers are displayed at the top (Gonna do some of my own adjusting to make the gap not so big) but the plugin itself is perfect, second pic is how I went ahead and arrange it on the damage.png, and then the last how I placed the code in the JS file, just for anyone in the future looking for the same thing and happen upon this post.

Will close the thread when I get the time to log back in, thank you again (again) so much!!

Oh and if the project I am working on ever comes to fruition I'll be sure to include you in credits! I appreciate any help I can get.
This thread is closed due to being reported as solved. If you need it reopened, let us know. Thank you!

Original thread: https://forums.rpgmakerweb.com/threads/commas-in-damage-number-pop-ups-in-combat.169020/