Javascript Intervals
Hello im trying to make a simple game where user chose a tool then use it and get items from that, but when i try to add intervals for mining im getting small issue. When i use tool with some id it works great but when i try to use that tool again (with same id) interval goes faster
here is the code:
4 Replies
I'm guessing you're not clearing the interval
the interval will keep triggering until you call
clearInterval
, passing it the return value of the initial setInterval
call (so miningIntervals[tool.id]
in this case)
just calling delete on miningIntervals[tool.id]
won't work, that just destroys the value you can use to clear the interval, so you'd want to change that line to something like
i have used
clearInterval()
but placed it in wrong line
tysm ❤️no worries, glad to help 🙂