Navigation

    Fuze Arena Logo
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Help
    • Discord

    how do I make it wait?

    Help
    2
    3
    319
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T
      TwentyVyrus last edited by

      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?

      spikey 1 Reply Last reply Reply Quote 0
      • spikey
        spikey F @TwentyVyrus last edited by spikey

        @twentyvyrus you can use time()

        _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
        
        T 1 Reply Last reply Reply Quote 4
        • T
          TwentyVyrus @spikey last edited by

          @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!

          1 Reply Last reply Reply Quote 2
          • First post
            Last post