Navigation

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

    setTimer() problems

    Bug Reporting (FUZE 4 Nintendo Switch)
    2
    4
    244
    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.
    • LinkCraft
      LinkCraft F last edited by

      I love using setTimer but it sometimes gives me grief. For example I’ll do something like:

      setTimer(1,1,function( ))
      
      Function function()
      //stuff
      Return //more stuff 
      

      And I’ll get an error like incorrect number of perimeters for function or something like that.

      But if I add

      Print( )
      

      With nothing in it before setTimer I get no error.
      But sometimes I’ll get a
      unrecognized Type -6392748503736 error
      I don’t even know what it means and the number is always different. and when I run the program again it will run for like 5 min doing nothing and then the unrecognized type error will just randomly pull up.

      1 Reply Last reply Reply Quote 0
      • Martin
        Martin Fuze Team last edited by

        Timers unfortunately can be a bit buggy. How literal is your example there? Because that timer is going to fire once and once only after a second. So I'm guessing that not really what you're doing.

        I have this code and so far have never hit a problem

        _waveTimer = setTimer(audioLength(sndWave) - 0.2, -1, startWave())
        stopTimer(_waveTimer)
        

        The idea is that I setup a timer that is used to delay the start of a new wave long enough to just about let the sound play. I set it up and stop it immediately. Then at the start of a new level I start the timer, there's a bit of a delay and then startWave() is called which pretty much just turns the timer back off again:

        function startWave()
            stopTimer(_waveTimer)
            game.waveStart = false
            game.wavePause = 0
        return void
        

        SO, two key differences - I don't leave a long running timer going and the iterations is basically set to "indefinite"

        Don't really know if any of this info is likely to help or not.

        1 Reply Last reply Reply Quote 0
        • LinkCraft
          LinkCraft F last edited by

          My example is not very literal what I have is a selection box that moves over once then sets the timer for .25 seconds then it lets you move the box again so the timer can only fire once it finishes and you move the box. Also I added a second print( ) before the timer and I get no errors

          earlier I added a clear( ) before the timer and there are no errors but the screen flashes so that did not work.

          I don’t know why but adding
          Print()
          Print()
          Before a timer fixes it.

          1 Reply Last reply Reply Quote 0
          • LinkCraft
            LinkCraft F last edited by

            So I have it working just I run into errors with setTimer() almost every time I use it

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