Advertisement
VasVadum

Javascript Mining Calc

Sep 11th, 2012
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script type="text/javascript">
  2. function formatSeconds(output) {
  3.     var seconds = 0;
  4.     var minutes = 0;
  5.     var hours = 0;
  6.     var days = 0;
  7.     var weeks = 0;
  8.     var years = 0;
  9.    
  10.     while (milliseconds >= 1000) {
  11.         milliseconds -= 1000;
  12.         seconds += 1;
  13.     }
  14.    
  15.     while (seconds >= 60) {
  16.         seconds -= 60;
  17.         minutes += 1;
  18.     }
  19.    
  20.     while (minutes >= 60) {
  21.         minutes -= 60;
  22.         hours += 1;
  23.     }
  24.    
  25.     while (hours >= 24) {
  26.         hours -=24;
  27.         days += 1;
  28.     }
  29.  
  30.     while (days >= 7) {
  31.         days -= 7;
  32.         weeks += 1;
  33.     }
  34.    
  35.     while (weeks >= 52) {
  36.         weeks -= 52;
  37.         years += 1;
  38.     }
  39.    
  40.     return [years, weeks, days, hours, minutes, seconds, milliseconds];
  41. }
  42.  
  43. function printFormat(array) {
  44.     if (array[0] !== 0) {
  45.         console.log(array[0] + " Years,");
  46.     }
  47.     if (array[1] !== 0) {
  48.         console.log(array[1] + " Weeks,");
  49.     }
  50.     if (array[2] !== 0) {
  51.         console.log(array[2] + " Days,");
  52.     }
  53.     if (array[3] !== 0) {
  54.         console.log(array[3] + " Hours,");
  55.     }
  56.     if (array[4] !== 0) {
  57.         console.log(array[4] + " Minutes,");
  58.     }
  59.     if (array[5] !== 0) {
  60.         console.log(array[5] + " Seconds");
  61.     }
  62.     if (array[6] !== 0) {
  63.         console.log(array[6] + " Milliseconds");
  64.     }
  65.     return;
  66. }
  67.  
  68. var seconds = prompt("How many seconds does it take you to complete one cycle? Please use all decimals if you want more accuracy.");
  69. var cycle =  prompt("How much do you get per cycle? Please use all decimals if you want more accuracy.");
  70. var lasers = prompt("How many strip miners or mining lasers are you using?");
  71. var storage = prompt("How large is the container you are trying to fill? No need to type m3 or cubic meters.");
  72.  
  73. var output = (seconds / (cycle * lasers)) * storage;
  74. //var output = (120 / (2000 * 3)) * 50000; = 1000?
  75.  
  76. console.log(output);
  77.  
  78. printFormat(formatSeconds(output));
  79. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement