Cookie Clicker

Cookie Clicker

Cookie Clicker Workshop
Tune your cookie-clicking experience just right with quality-of-life tools, extra player-made content or just dirty dirty hacks.
Learn More
Magicalus 3 Aug, 2022 @ 8:18pm
Need help with a notation mod
I'm trying to make a mod that could change the format numbers to various notations(for simplicity, lets say I'm only trying to make it run scientific notation). I think this part of the code is the part where the displayed cookies are defined(right at the start of the draw() function):

var str=Beautify(Math.round(Game.cookiesd));
if (Game.cookiesd>=1000000)//dirty padding
{
var spacePos=str.indexOf(' ');
var dotPos=str.indexOf('.');
var add='';
if (spacePos!=-1)
{
if (dotPos==-1) add+='.000';
else
{
if (spacePos-dotPos==2) add+='00';
if (spacePos-dotPos==3) add+='0';
}
}
str=[str.slice(0,spacePos),add,str.slice(spacePos)].join('');
}

str=loc("%1 cookie",{n:Math.round(Game.cookiesd),b:str});
if (str.length>14) str=str.replace(' ','<br>');

if (Game.prefs.monospace) str='<span class="monospace">'+str+'</span>';
str=str+'<div id="cookiesPerSecond"'+(Game.cpsSucked>0?' class="wrinkled"':'')+'>'+loc("per second:")+' '+Beautify(Game.cookiesPs*(1-Game.cpsSucked),1)+'</div>';
l('cookies').innerHTML=str;
Timer.track('cookie amount');

How could I modify this to my desired notation?(And if possible, in a way that I can reuse for other numbers). Better yet, is there a way to modify it universally?
Last edited by Magicalus; 3 Aug, 2022 @ 8:30pm