I am struggling to figure out how to use a timer.

I just added this timer code:

var timer

func init():
timer = Timer.new()
add_child(timer)
timer.autostart = true
timer.wait_time = 4.0
timer.connect("timeout", self, "
timeout")

I get this error:
Invalid type in function 'connect' in base 'Timer'. Cannot convert argument 2 from String to Callable.

Not sure why as this is right out of a tutorial...
Any help is much appreciated.

  • xyz replied to this.
  • OhioG You're trying to use 3.x code in 4.0. Try:

    timer.connect("timeout", self.timeout)

    Btw it'd be better to use a different name for the callback function so it differs from the signal name.

    OhioG You're trying to use 3.x code in 4.0. Try:

    timer.connect("timeout", self.timeout)

    Btw it'd be better to use a different name for the callback function so it differs from the signal name.

      xyz I can not thank you enough. I have been banging my head against this for a day plus.

      Much Appreciated!