how do I make it wait?
I'm trying to make a game where you click a and it gives you a bronze coin, 100 bronze coins make a silver coin and 100 silver coins make a gold coin. You can buy upgrades so you get more bronze coins per click but I'm making a new upgrade so every second you get a bronze coin without having to to anything here is the code:
if sils == false and sil > 49 then printat(0, 8 , "press right d-pad to buy a silversmith") if c.right and !oldc.right then sil -= 50 sils = true endif endif if sils == true then brz+= 1 endif
but I want it to wait a second after giving a bronze coin but when I put a sleep(1) after brz += 1 then it makes everything else wait aswell. How could I separate the rest of the code from this section so it will wait but everythong else goes on as normal?
@twentyvyrus you can use
_lastTime = time() // global variable INTERVAL = 5 // seconds between action // main loop loop if (time() - _lastTime) >= INTERVAL then // Increase your value or do any other timed action _lastTime = time() // reinit your timer endif repeat
@spikey thanks it worked although the whole thing is still a little bit confusing to me so im gonna have to keep practicing with the time function!