• Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

JavaScript This doesn't make any sense!

Omnomc

New Coder
So, I have been working on a cookie clicker game and this happened.
I saved with 1+ auto-clicker and (make sure to refresh in-between) loaded the game and when I brought the next auto-clicker, the cookies per second went exponentially high.
Please try this code for yourself.
Any help greatly appreciated!
Code:
<!DOCTYPE html>
<html>
<head><title>hey</title>
<script>
var Cookies = 0
var autoClickers = 0
var loopRunningAutoClickers = false
var bakers = 0
var loopRunningBakers = false
var farms = 0
var loopRunningFarms = false

function save() {
   localStorage.cookies = Cookies
   localStorage.autoClickers = autoClickers
   localStorage.bakers = bakers
   localStorage.farms = farms
   if (autoClickers >= 1) {
      localStorage.storeAutoClickerLoop = 1
   }
   if (bakers >= 1) {
      localStorage.storeBakerLoop = 1
   }
   if (farm >= 1) {
      localStorage.storeFarmLoop = 1
   }
}

function load() {
   Cookies = localStorage.cookies
   Cookies = parseInt(Cookies)
   autoClickers = localStorage.autoClickers
   bakers = localStorage.bakers
   farms = localStorage.farms
   if (localStorage.storeAutoClickerLoop == 1) {
      autoClickerLoop()
      loopRunningAutoClickers = true
   }
   if (localStorage.storeBakerLoop == 1) {
      bakerLoop()
      loopRunningBakers = true
   }
   if (localStorage.storeFarmLoop == 1) {
      farmLoop()
      loopRunningFarms = true
   }
   if (Cookies < 1000) {
      document.getElementById("CookieCounter").value = Cookies + " Cookies!"
   }
   if (Cookies >= 1000) {
      document.getElementById("CookieCounter").value = (Cookies / 1000).toFixed(3).replace(/\.0$/, ' ') + "K Cookies!"
   }
   if (Cookies >= 1000000) {
      document.getElementById("CookieCounter").value = (Cookies / 1000000).toFixed(3).replace(/\.0$/, ' ') + "M Cookies!"
   }
   if (Cookies >= 1000000000) {
      document.getElementById("CookieCounter").value = (Cookies / 1000000000).toFixed(3).replace(/\.0$/, ' ') + "B Cookies!"
   }
   if (Cookies >= 1000000000000) {
      document.getElementById("CookieCounter").value = (Cookies / 1000000000000).toFixed(3).replace(/\.0$/, ' ') + "T Cookies!"
   }
  
}
function addCookie() {
   Cookies += 1
   if (Cookies < 1000) {
      document.getElementById("CookieCounter").value = Cookies + " Cookies!"
   }
   if (Cookies >= 1000) {
      document.getElementById("CookieCounter").value = (Cookies / 1000).toFixed(3).replace(/\.0$/, ' ') + "K Cookies!"
   }
   if (Cookies >= 1000000) {
      document.getElementById("CookieCounter").value = (Cookies / 1000000).toFixed(3).replace(/\.0$/, ' ') + "M Cookies!"
   }
   if (Cookies >= 1000000000) {
      document.getElementById("CookieCounter").value = (Cookies / 1000000000).toFixed(3).replace(/\.0$/, ' ') + "B Cookies!"
   }
   if (Cookies >= 1000000000000) {
      document.getElementById("CookieCounter").value = (Cookies / 1000000000000).toFixed(3).replace(/\.0$/, ' ') + "T Cookies!"
   }
}
 
function autoClickerBrought() {
   if (Cookies > 49) {
   Cookies -= 50
   if (Cookies < 1000) {
      document.getElementById("CookieCounter").value = Cookies + " Cookies!"
   }
   if (Cookies >= 1000) {
      document.getElementById("CookieCounter").value = (Cookies / 1000).toFixed(3).replace(/\.0$/, ' ') + "K Cookies!"
   }
   if (Cookies >= 1000000) {
      document.getElementById("CookieCounter").value = (Cookies / 1000000).toFixed(3).replace(/\.0$/, ' ') + "M Cookies!"
   }
   if (Cookies >= 1000000000) {
      document.getElementById("CookieCounter").value = (Cookies / 1000000000).toFixed(3).replace(/\.0$/, ' ') + "B Cookies!"
   }
   if (Cookies >= 1000000000000) {
      document.getElementById("CookieCounter").value = (Cookies / 1000000000000).toFixed(3).replace(/\.0$/, ' ') + "T Cookies!"
   }
      autoClickers += 1
      if (loopRunningAutoClickers == false) {
         autoClickerLoop()
      }
      loopRunningAutoClickers = true
   }
}
function autoClickerLoop() {
   loopRunningAutoClickers = true
   Cookies += (autoClickers * 1)
   if (Cookies < 1000) {
      document.getElementById("CookieCounter").value = Cookies + " Cookies!"
   }
   if (Cookies >= 1000) {
      document.getElementById("CookieCounter").value = (Cookies / 1000).toFixed(3).replace(/\.0$/, ' ') + "K Cookies!"
   }
   if (Cookies >= 1000000) {
      document.getElementById("CookieCounter").value = (Cookies / 1000000).toFixed(3).replace(/\.0$/, ' ') + "M Cookies!"
   }
   if (Cookies >= 1000000000) {
      document.getElementById("CookieCounter").value = (Cookies / 1000000000).toFixed(3).replace(/\.0$/, ' ') + "B Cookies!"
   }
   if (Cookies >= 1000000000000) {
      document.getElementById("CookieCounter").value = (Cookies / 1000000000000).toFixed(3).replace(/\.0$/, ' ') + "T Cookies!"
   }
   setTimeout(autoClickerLoop, 1000)
}
function bakerBrought() {
   if (Cookies > 1999) {
      Cookies -= 2000
   if (Cookies < 1000) {
      document.getElementById("CookieCounter").value = Cookies + " Cookies!"
   }
   if (Cookies >= 1000) {
      document.getElementById("CookieCounter").value = (Cookies / 1000).toFixed(3).replace(/\.0$/, ' ') + "K Cookies!"
   }
   if (Cookies >= 1000000) {
      document.getElementById("CookieCounter").value = (Cookies / 1000000).toFixed(3).replace(/\.0$/, ' ') + "M Cookies!"
   }
   if (Cookies >= 1000000000) {
      document.getElementById("CookieCounter").value = (Cookies / 1000000000).toFixed(3).replace(/\.0$/, ' ') + "B Cookies!"
   }
   if (Cookies >= 1000000000000) {
      document.getElementById("CookieCounter").value = (Cookies / 1000000000000).toFixed(3).replace(/\.0$/, ' ') + "T Cookies!"
   }
      bakers += 1
      if (loopRunningBakers == false) {
       bakerLoop()
      }
      loopRunningBakers = true
   }
}
function bakerLoop() {
   loopRunningBakers = true
   Cookies += (bakers * 30)
   if (Cookies < 1000) {
      document.getElementById("CookieCounter").value = Cookies + " Cookies!"
   }
   if (Cookies >= 1000) {
      document.getElementById("CookieCounter").value = (Cookies / 1000).toFixed(3).replace(/\.0$/, ' ') + "K Cookies!"
   }
   if (Cookies >= 1000000) {
      document.getElementById("CookieCounter").value = (Cookies / 1000000).toFixed(3).replace(/\.0$/, ' ') + "M Cookies!"
   }
   if (Cookies >= 1000000000) {
      document.getElementById("CookieCounter").value = (Cookies / 1000000000).toFixed(3).replace(/\.0$/, ' ') + "B Cookies!"
   }
   if (Cookies >= 1000000000000) {
      document.getElementById("CookieCounter").value = (Cookies / 1000000000000).toFixed(3).replace(/\.0$/, ' ') + "T Cookies!"
   }
   setTimeout(bakerLoop, 1000)
}
function farmBrought() {
   if (Cookies > 350000) {
      Cookies -= 350000
   if (Cookies < 1000) {
      document.getElementById("CookieCounter").value = Cookies + " Cookies!"
   }
   if (Cookies >= 1000) {
      document.getElementById("CookieCounter").value = (Cookies / 1000).toFixed(3).replace(/\.0$/, ' ') + "K Cookies!"
   }
   if (Cookies >= 1000000) {
      document.getElementById("CookieCounter").value = (Cookies / 1000000).toFixed(3).replace(/\.0$/, ' ') + "M Cookies!"
   }
   if (Cookies >= 1000000000) {
      document.getElementById("CookieCounter").value = (Cookies / 1000000000).toFixed(3).replace(/\.0$/, ' ') + "B Cookies!"
   }
   if (Cookies >= 1000000000000) {
      document.getElementById("CookieCounter").value = (Cookies / 1000000000000).toFixed(3).replace(/\.0$/, ' ') + "T Cookies!"
   }
      farms += 1
      if (loopRunningFarms == false) {
         farmLoop()
      }
      loopRunningFarms = true
   }
}
function farmLoop() {
   loopRunningFarms = true
   Cookies += (farms * 2000)
   if (Cookies < 1000) {
      document.getElementById("CookieCounter").value = Cookies + " Cookies!"
   }
   if (Cookies >= 1000) {
      document.getElementById("CookieCounter").value = (Cookies / 1000).toFixed(3).replace(/\.0$/, ' ') + "K Cookies!"
   }
   if (Cookies >= 1000000) {
      document.getElementById("CookieCounter").value = (Cookies / 1000000).toFixed(3).replace(/\.0$/, ' ') + "M Cookies!"
   }
   if (Cookies >= 1000000000) {
      document.getElementById("CookieCounter").value = (Cookies / 1000000000).toFixed(3).replace(/\.0$/, ' ') + "B Cookies!"
   }
   if (Cookies >= 1000000000000) {
      document.getElementById("CookieCounter").value = (Cookies / 1000000000000).toFixed(3).replace(/\.0$/, ' ') + "T Cookies!"
   }
   setTimeout(farmLoop, 1000)
}
</script>
<style>
</style>
</head>
<body>
<input type="text" id="CookieCounter" value="0 Cookies!" disabled style="text-align: center">
<input type="button" value="Save" onclick="save()">
<input type="button" value="Load" onclick="load()">
<img src="Cookie.jpg" onclick="addCookie()">
<input type="button" value="Auto-Clicker. Cost: 50 Cookies, + 1 Cookies Per Second" onclick="autoClickerBrought()">
<input type="button" value="Baker. Cost: 2,000 Cookies, + 30 Cookies Per Second" onclick="bakerBrought()">
<input type="button" value="Farm. Cost: 250,000 Cookies, + 2,000 Cookies Per Second" onclick="farmBrought()">
</body>
</html>
(make sure to make an cookie image or change it to a button).
Any help absolutely greatly appreciated!
 

Top