Updated this thread to show my bookmarklets and give a link to where I will put any other scripts I write for IGM.
Import/Export saves:
javascript:(function(){with(document)(head.appendChild(createElement('script')).src='http://pastebin.com/raw.php?i=C1kJemmr')._})();
Adds Import/Export buttons to the save box and a text box. The export save button outputs the code to the text box. The import one brings up a prompt.
Buy 10/100 of a building at a time:
javascript:(function(){with(document)(head.appendChild(createElement('script')).src='http://pastebin.com/raw.php?i=hCTuvzBf')._})();
Adds a drop menu containing all visible buildings and buy 10/buy 100 buttons to the save box. Currently you will need to refresh the page and reload the script after new buildings are unlocked.
If you try to use it to buy a building that is no longer visible then nothing will happen. It also stops buying it if the building is locked while being bought. So don't think about using it to cheat! :P
Short numbers:
javascript:with(document)(head.appendChild(createElement('script')).src='http://pastebin.com/raw.php?i=bZVxKpGH')._
Changes numbers to have k, M etc. Can be customised by setting nums as an array using the letter(s) you want after the powers of 1,000. Must start at 1,000 and go up in powers of 1,000. You can use as many or as few as you want.
Misc scripts:
//Output the number of each building owned to the console:
keys(Game.buildings).reduce(function(p,c){
if(Game.buildings[c].visible)
{
buildamount = (Game.buildings[c].name + ': ' + Game.buildings[c].amount + ', ')
}
else buildamount = ''
return p + buildamount},'')
//output the income of each resource to the console:
keys(Game.res).reduce(function(p,c){
if(Game.res[c].visible && Game.res[c].computedPS > 0)
{
resincome = ('\n' + Game.res[c].name + ': ' + Beautify(Game.res[c].computedPS) + '/s');
}
else resincome = ''
return p + resincome},'')
/*output to the console the remaining achievements not won and if applicable how many resources/buildings needed (doesn't show when it is unlocked on the purchase of something:*/
achievementsleft = '\n'
for(i in Game.achievements)
{
if(Game.achievements[i].won == 0)
{
achievementsleft += Game.achievements[i].name + ': \n'
for(j in Game.achievements[i].unlocksAt)
{
achievementsleft += "\n " + Beautify(Game.achievements[i].unlocksAt[j].amount) + ' ' + Game.achievements[i].unlocksAt[j].X.name
}
achievementsleft += "\n \n"
}
}
console.log(achievementsleft)
That would be simple as I could reuse most of my previous scripts. I will do something like that when I get time (and feel like it :P) since it would be helpful for IGM game devs too.
I could also do it so you could choose to unlock certain upgrades but it'd be a huge list for some games. :P
Unless someone else wants to do it? This is the script that writes the HTML for the buildings drop down menu:
var multbuyopt = '';
for(i in Object.keys(Game.buildings)){
if(Game.buildings[Object.keys(Game.buildings)[i]].visible){
multbuyopt+= "
Post edited by Chisako on
I had a dream my life would be So different from this hell I'm living So different now, from what it seemed Now life has killed the dream I dreamed
0
TelluriumFriendly, Cool, Idle Game Master, Conversationalist, TurquoisePosts: 5,382Mod
If you're taking suggestions, I recommend a number shortener like in Cookie Clicker to avoid 1+e21ing.
tellurium said:
If you're taking suggestions, I recommend a number shortener like in Cookie Clicker to avoid 1+e21ing.
That can be done by using the same functions that do it in CC. I am a bit reluctant to rehost code but this is the code needed:
function formatEveryThirdPower(notations)
{
return function (value)
{
var base = 0,
notationValue = '';
if (value >= 1000000 && isFinite(value))
{
value /= 1000;
while(Math.round(value) >= 1000)
{
value /= 1000;
base++;
}
if (base > notations.length) {return 'Infinity';} else {notationValue = notations[base];}
}
return ( Math.round(value * 1000) / 1000 ) + notationValue;
};
}
function rawFormatter(value) {return Math.round(value * 1000) / 1000;}
var numberFormatters =
[
rawFormatter,
formatEveryThirdPower(['',' million',' billion',' trillion',' quadrillion',' quintillion',' sextillion',' septillion',' octillion',' nonillion',' decillion']),formatEveryThirdPower(['',' M',' B',' T',' Qa',' Qi',' Sx',' Sp',' Oc',' No',' Dc'])];
function Beautify(value,floats)
{
var negative=(value<0);
var decimal='';
if (value<1000000 && floats>0) decimal='.'+(value.toFixed(floats).toString()).split('.')[1];
value=Math.floor(Math.abs(value));
var formatter=numberFormatters[1];
var output=formatter(value).toString().replace(/\B(?=(\d{3})+(?!\d))/g,',');
return negative?'-'+output:output+decimal;
}
Post edited by Chisako on
I had a dream my life would be So different from this hell I'm living So different now, from what it seemed Now life has killed the dream I dreamed
0
MasterSparkyMember, Internet Detective, Helpful, Flagger, Idle Game Master, ConversationalistPosts: 14,654✭✭✭✭✭✭
I have updated it so it no longer jumps all over the place.
function Beautify(num,floats)
{
if (!isFinite(num)) return 'Infinity';
if(num < 1e3 || num >= 1e36) return Math.round(num);
nums = ['k','M','B','T','Q','Qi', 'Sx', 'Sp', 'Oc', 'No', 'De'];
var i = 0;
while(num >= 1000)
{
num/=1000;
i++;
}
num = Math.round(num*1000)/1000;
num = num.toString();
if(num.indexOf('.') == -1) num += '.000';
else
{
dec = num.indexOf('.');
while(num.slice(dec,num.length).length < 4) num += '0';
}
return num + nums[i - 1];
}
Now instead of giving 100.1M it'll give 100.100M which stops the numbers being really jerky.
Edit:
If I ever get round to making my own idle game I have a function to format numbers now. :P
Post edited by Chisako on
I had a dream my life would be So different from this hell I'm living So different now, from what it seemed Now life has killed the dream I dreamed
0
MasterSparkyMember, Internet Detective, Helpful, Flagger, Idle Game Master, ConversationalistPosts: 14,654✭✭✭✭✭✭
You guys are geniuses I feel so inadequate right now. ._.
"Monotheism is progress of a sort because they're getting nearer the true figure all the time." -C. Hitchens "After all, to the well-organized mind, death is but the next great adventure." -A. Dumbledore "If you want to know what a man's like, take a good look at how he treats his inferiors, not his equals." -S. Black “Confidence is ignorance. If you're feeling cocky, it's because there's something you don't know.” -Foaly the Centaur
0
MasterSparkyMember, Internet Detective, Helpful, Flagger, Idle Game Master, ConversationalistPosts: 14,654✭✭✭✭✭✭
You guys are geniuses I feel so inadequate right now. ._.
I'm not a genius, I just changed the letters in the brackets
But...but...you can understand what it says. ._.
"Monotheism is progress of a sort because they're getting nearer the true figure all the time." -C. Hitchens "After all, to the well-organized mind, death is but the next great adventure." -A. Dumbledore "If you want to know what a man's like, take a good look at how he treats his inferiors, not his equals." -S. Black “Confidence is ignorance. If you're feeling cocky, it's because there's something you don't know.” -Foaly the Centaur
0
MasterSparkyMember, Internet Detective, Helpful, Flagger, Idle Game Master, ConversationalistPosts: 14,654✭✭✭✭✭✭
It was easy enough to find the "k,M,B,T..." part and change the text :P
I've updated the script again now firstly due to it causing a rounding error at times and giving 1000No instead of 1De and secondly to make it customisable:
nums = ['k','M','B','T','Q','Qi', 'Sx', 'Sp', 'Oc', 'No', 'De'];
function Beautify(num,floats)
{
if (!isFinite(num)) return 'Infinity';
if(num < 1e3 || num >= parseFloat('1e' + 3*(nums.length + 1))) return Math.round(num);
var i = 0;
while(num >= 1000)
{
num/=1000;
i++;
}
num = Math.round(num*1000)/1000;
if(num>=1000)
{
num/=1000;
i++;
num = Math.round(num*1000)/1000;
} //deals with rounding errors
num = num.toString();
if(num.indexOf('.') == -1) num += '.000';
else
{
dec = num.indexOf('.');
while(num.slice(dec,num.length).length < 4) num += '0'; //adds trailing 0s (if needed) to stop the numbers jumping around.
}
return num + nums[i - 1];
}
You define nums as an array of powers of 1k starting at 1k. You can make it as long or as short as you want. It should just return the original number if it is larger than the highest one in the array allows.
Post edited by Chisako on
I had a dream my life would be So different from this hell I'm living So different now, from what it seemed Now life has killed the dream I dreamed
1
MasterSparkyMember, Internet Detective, Helpful, Flagger, Idle Game Master, ConversationalistPosts: 14,654✭✭✭✭✭✭
Comments
So different from this hell I'm living
So different now, from what it seemed
Now life has killed the dream I dreamed
Try to make one that lets you cheat (With add # of buildings or resources)
I could also do it so you could choose to unlock certain upgrades but it'd be a huge list for some games. :P
Unless someone else wants to do it? This is the script that writes the HTML for the buildings drop down menu:
var multbuyopt = '';
for(i in Object.keys(Game.buildings)){
if(Game.buildings[Object.keys(Game.buildings)[i]].visible){
multbuyopt+= "
So different from this hell I'm living
So different now, from what it seemed
Now life has killed the dream I dreamed
If you're taking suggestions, I recommend a number shortener like in Cookie Clicker to avoid 1+e21ing.
That can be done by using the same functions that do it in CC. I am a bit reluctant to rehost code but this is the code needed:
function formatEveryThirdPower(notations)
{
return function (value)
{
var base = 0,
notationValue = '';
if (value >= 1000000 && isFinite(value))
{
value /= 1000;
while(Math.round(value) >= 1000)
{
value /= 1000;
base++;
}
if (base > notations.length) {return 'Infinity';} else {notationValue = notations[base];}
}
return ( Math.round(value * 1000) / 1000 ) + notationValue;
};
}
function rawFormatter(value) {return Math.round(value * 1000) / 1000;}
var numberFormatters =
[
rawFormatter,
formatEveryThirdPower(['',' million',' billion',' trillion',' quadrillion',' quintillion',' sextillion',' septillion',' octillion',' nonillion',' decillion']),formatEveryThirdPower(['',' M',' B',' T',' Qa',' Qi',' Sx',' Sp',' Oc',' No',' Dc'])];
function Beautify(value,floats)
{
var negative=(value<0);
var decimal='';
if (value<1000000 && floats>0) decimal='.'+(value.toFixed(floats).toString()).split('.')[1];
value=Math.floor(Math.abs(value));
var formatter=numberFormatters[1];
var output=formatter(value).toString().replace(/\B(?=(\d{3})+(?!\d))/g,',');
return negative?'-'+output:output+decimal;
}
So different from this hell I'm living
So different now, from what it seemed
Now life has killed the dream I dreamed
"It's a nice feeling to be put in a sig." ~Tellurium | "sparky why isn't 'holy fuck sparky' in your sig" ~DMF
"in my 10(-3) months living in dashnet i have never been sigged for more than like 30 minutes" ~lennonluiz0907
"please get sigged, please, please!" ~MCVIII | "Wow, Sparky's sig is just about others talking about sigs." ~DS1.8K
"LEGENDS ARE MADE BY SPARKY'S SIGNATURE" ~C_N | "I actually kind of want to be in Sparky's sig." ~CWS
"I feel like I'm the only guy here with a full sig of quotes that don't have meta-humor involved." ~CWS
So different from this hell I'm living
So different now, from what it seemed
Now life has killed the dream I dreamed
nums = ['k','M','B','T','Q','Qi', 'Sx', 'Sp', 'Oc', 'No', 'De'];
function Beautify(num,floats)
{
if (!isFinite(num)) return 'Infinity';
if(num < 1e3 || num >= parseFloat('1e' + 3*(nums.length + 1))) return Math.round(num);
var i = 0;
while(num >= 1000)
{
num/=1000;
i++;
}
num = Math.round(num*1000)/1000;
if(num>=1000)
{
num/=1000;
i++;
num = Math.round(num*1000)/1000;
} //deals with rounding errors
num = num.toString();
if(num.indexOf('.') == -1) num += '.000';
else
{
dec = num.indexOf('.');
while(num.slice(dec,num.length).length < 4) num += '0'; //adds trailing 0s (if needed) to stop the numbers jumping around.
}
return num + nums[i - 1];
}
So different from this hell I'm living
So different now, from what it seemed
Now life has killed the dream I dreamed
Edit: adapted for SI
function Beautify(num,floats) { if (!isFinite(num)) return 'Infinity'; if(num < 1e3 || num >= 1e36) return Math.round(num) nums = ['k','M','G','T','P','E','Z','Y','X','V','U'] var i = 0 while(num >= 1000) { num/=1000 i++ } num = Math.round(num*1000)/1000 return '' + num + nums[i - 1]; }
function Beautify(num,floats) { if (!isFinite(num)) return 'Infinity'; if(num < 1e3 || num >= 1e36) return Math.round(num) nums = [' kilo ',' mega',' giga',' tera',' peta',' exa',' zetta',' yotta',' xatta',' vitta',' uktta'] var i = 0 while(num >= 1000) { num/=1000 i++ } num = Math.round(num*1000)/1000 return '' + num + nums[i - 1]; }
"It's a nice feeling to be put in a sig." ~Tellurium | "sparky why isn't 'holy fuck sparky' in your sig" ~DMF
"in my 10(-3) months living in dashnet i have never been sigged for more than like 30 minutes" ~lennonluiz0907
"please get sigged, please, please!" ~MCVIII | "Wow, Sparky's sig is just about others talking about sigs." ~DS1.8K
"LEGENDS ARE MADE BY SPARKY'S SIGNATURE" ~C_N | "I actually kind of want to be in Sparky's sig." ~CWS
"I feel like I'm the only guy here with a full sig of quotes that don't have meta-humor involved." ~CWS
function Beautify(num,floats)
{
if (!isFinite(num)) return 'Infinity';
if(num < 1e3 || num >= 1e36) return Math.round(num);
nums = ['k','M','B','T','Q','Qi', 'Sx', 'Sp', 'Oc', 'No', 'De'];
var i = 0;
while(num >= 1000)
{
num/=1000;
i++;
}
num = Math.round(num*1000)/1000;
num = num.toString();
if(num.indexOf('.') == -1) num += '.000';
else
{
dec = num.indexOf('.');
while(num.slice(dec,num.length).length < 4) num += '0';
}
return num + nums[i - 1];
}
Now instead of giving 100.1M it'll give 100.100M which stops the numbers being really jerky.
Edit:
If I ever get round to making my own idle game I have a function to format numbers now. :P
So different from this hell I'm living
So different now, from what it seemed
Now life has killed the dream I dreamed
"It's a nice feeling to be put in a sig." ~Tellurium | "sparky why isn't 'holy fuck sparky' in your sig" ~DMF
"in my 10(-3) months living in dashnet i have never been sigged for more than like 30 minutes" ~lennonluiz0907
"please get sigged, please, please!" ~MCVIII | "Wow, Sparky's sig is just about others talking about sigs." ~DS1.8K
"LEGENDS ARE MADE BY SPARKY'S SIGNATURE" ~C_N | "I actually kind of want to be in Sparky's sig." ~CWS
"I feel like I'm the only guy here with a full sig of quotes that don't have meta-humor involved." ~CWS
"After all, to the well-organized mind, death is but the next great adventure." -A. Dumbledore
"If you want to know what a man's like, take a good look at how he treats his inferiors, not his equals." -S. Black
“Confidence is ignorance. If you're feeling cocky, it's because there's something you don't know.” -Foaly the Centaur
"It's a nice feeling to be put in a sig." ~Tellurium | "sparky why isn't 'holy fuck sparky' in your sig" ~DMF
"in my 10(-3) months living in dashnet i have never been sigged for more than like 30 minutes" ~lennonluiz0907
"please get sigged, please, please!" ~MCVIII | "Wow, Sparky's sig is just about others talking about sigs." ~DS1.8K
"LEGENDS ARE MADE BY SPARKY'S SIGNATURE" ~C_N | "I actually kind of want to be in Sparky's sig." ~CWS
"I feel like I'm the only guy here with a full sig of quotes that don't have meta-humor involved." ~CWS
"After all, to the well-organized mind, death is but the next great adventure." -A. Dumbledore
"If you want to know what a man's like, take a good look at how he treats his inferiors, not his equals." -S. Black
“Confidence is ignorance. If you're feeling cocky, it's because there's something you don't know.” -Foaly the Centaur
"It's a nice feeling to be put in a sig." ~Tellurium | "sparky why isn't 'holy fuck sparky' in your sig" ~DMF
"in my 10(-3) months living in dashnet i have never been sigged for more than like 30 minutes" ~lennonluiz0907
"please get sigged, please, please!" ~MCVIII | "Wow, Sparky's sig is just about others talking about sigs." ~DS1.8K
"LEGENDS ARE MADE BY SPARKY'S SIGNATURE" ~C_N | "I actually kind of want to be in Sparky's sig." ~CWS
"I feel like I'm the only guy here with a full sig of quotes that don't have meta-humor involved." ~CWS
function Beautify(num,floats) { if (!isFinite(num)) return 'Infinity'; if(num < 1e3) return Math.round(num) nums = ['K','M','G','T','P','E','Z','Y','U','S','H','F','L','W','KW','MW','GW','TW','PW','EW','ZW','YW','UW','SW','HW','FW','LW','WW','KWW','MWW','GWW','TWW','PWW','EWW','ZWW','YWW','UWW','SWW','HWW','FWW','LWW','WWW','KWWW','MWWW','GWWW','TWWW','PWWW','EWWW','ZWWW','YWWW','UWWW','SWWW','HWWW','FWWW','LWWW','WWWW','KWWWW','MWWWW','GWWWW','TWWWW','PWWWW','EWWWW','ZWWWW','YWWWW','UWWWW','SWWWW','HWWWW','FWWWW','LWWWW','Q','KQ','MQ','GQ','TQ','PQ','EQ','ZQ','YQ','UQ','SQ','HQ','FQ','LQ','WQ','KWQ','MWQ','GWQ','TWQ','PWQ','EWQ','ZWQ','YWQ','UWQ','SWQ','HWQ','FWQ','LWQ','WWQ','KWWQ','MWWQ','BWWQ','TWWQ'] var i = 0 while(num >= 1000) { num/=1000 i++ } num = Math.round(num*1000)/1000 return '' + num + nums[i - 1]; }
Improved SI version!
"It's a nice feeling to be put in a sig." ~Tellurium | "sparky why isn't 'holy fuck sparky' in your sig" ~DMF
"in my 10(-3) months living in dashnet i have never been sigged for more than like 30 minutes" ~lennonluiz0907
"please get sigged, please, please!" ~MCVIII | "Wow, Sparky's sig is just about others talking about sigs." ~DS1.8K
"LEGENDS ARE MADE BY SPARKY'S SIGNATURE" ~C_N | "I actually kind of want to be in Sparky's sig." ~CWS
"I feel like I'm the only guy here with a full sig of quotes that don't have meta-humor involved." ~CWS
It's easy to make a game that goes to Q though.
Also I made an error fixing.
Removed X and V (Sandcastle builder uses U, right?)
"It's a nice feeling to be put in a sig." ~Tellurium | "sparky why isn't 'holy fuck sparky' in your sig" ~DMF
"in my 10(-3) months living in dashnet i have never been sigged for more than like 30 minutes" ~lennonluiz0907
"please get sigged, please, please!" ~MCVIII | "Wow, Sparky's sig is just about others talking about sigs." ~DS1.8K
"LEGENDS ARE MADE BY SPARKY'S SIGNATURE" ~C_N | "I actually kind of want to be in Sparky's sig." ~CWS
"I feel like I'm the only guy here with a full sig of quotes that don't have meta-humor involved." ~CWS
nums = ['k','M','B','T','Q','Qi', 'Sx', 'Sp', 'Oc', 'No', 'De'];
function Beautify(num,floats)
{
if (!isFinite(num)) return 'Infinity';
if(num < 1e3 || num >= parseFloat('1e' + 3*(nums.length + 1))) return Math.round(num);
var i = 0;
while(num >= 1000)
{
num/=1000;
i++;
}
num = Math.round(num*1000)/1000;
if(num>=1000)
{
num/=1000;
i++;
num = Math.round(num*1000)/1000;
} //deals with rounding errors
num = num.toString();
if(num.indexOf('.') == -1) num += '.000';
else
{
dec = num.indexOf('.');
while(num.slice(dec,num.length).length < 4) num += '0'; //adds trailing 0s (if needed) to stop the numbers jumping around.
}
return num + nums[i - 1];
}
You define nums as an array of powers of 1k starting at 1k. You can make it as long or as short as you want. It should just return the original number if it is larger than the highest one in the array allows.
So different from this hell I'm living
So different now, from what it seemed
Now life has killed the dream I dreamed
"It's a nice feeling to be put in a sig." ~Tellurium | "sparky why isn't 'holy fuck sparky' in your sig" ~DMF
"in my 10(-3) months living in dashnet i have never been sigged for more than like 30 minutes" ~lennonluiz0907
"please get sigged, please, please!" ~MCVIII | "Wow, Sparky's sig is just about others talking about sigs." ~DS1.8K
"LEGENDS ARE MADE BY SPARKY'S SIGNATURE" ~C_N | "I actually kind of want to be in Sparky's sig." ~CWS
"I feel like I'm the only guy here with a full sig of quotes that don't have meta-humor involved." ~CWS
javascript: nums = ['K','M','G','T','P','E','Z','Y','U','S','H','F','L','W','KW','MW','GW','TW','PW','EW','ZW','YW','UW','SW','HW','FW','LW','WW','KWW','MWW','GWW','TWW','PWW','EWW','ZWW','YWW','UWW','SWW','HWW','FWW','LWW','WWW','KWWW','MWWW','GWWW','TWWW','PWWW','EWWW','ZWWW','YWWW','UWWW','SWWW','HWWW','FWWW','LWWW','WWWW','KWWWW','MWWWW','GWWWW','TWWWW','PWWWW','EWWWW','ZWWWW','YWWWW','UWWWW','SWWWW','HWWWW','FWWWW','LWWWW','Q','KQ','MQ','GQ','TQ','PQ','EQ','ZQ','YQ','UQ','SQ','HQ','FQ','LQ','WQ','KWQ','MWQ','GWQ','TWQ','PWQ','EWQ','ZWQ','YWQ','UWQ','SWQ','HWQ','FWQ','LWQ','WWQ','KWWQ','MWWQ','BWWQ','TWWQ']; function Beautify(num,floats) { if (!isFinite(num)) return 'Infinity'; if(num < 1e3 || num >= parseFloat('1e' + 3*(nums.length + 1))) return Math.round(num); var i = 0; while(num >= 1000) { num/=1000; i++; } num = Math.round(num*1000)/1000; if(num>=1000) { num/=1000; i++; num = Math.round(num*1000)/1000; } //deals with rounding errors num = num.toString(); if(num.indexOf('.') == -1) num += '.000'; else { dec = num.indexOf('.'); while(num.slice(dec,num.length).length < 4) num += '0'; //adds trailing 0s (if needed) to stop the numbers jumping around. } return num + nums[i - 1]; }
So uh...
I did something simple.
So different from this hell I'm living
So different now, from what it seemed
Now life has killed the dream I dreamed