How to create timer in Lua Server Runtime

I am new at Nakama and I wnat to use the server rumtime to creat the traffic light system, by putting the countdown timer and send the colour status to the game client. But I need to add the countdown finction, how to do that? It seems that I cannot use timer.performWithDelay and sleep etc?

Thanks!

You shouldn’t use Timers. Instead you should use an AuthoritativeMatch that sends the traffic light colours as per GameLoop invocation to your client(s).

Thanks for your direction, but should I use tick_rate to control the time of changing the traffic light signal? Thanks!

@whkhk yep, you can use the current tick and tick_rate within a match loop to infer elapsed time.

Thanks, and can I have a more guide about that, I am very new to this… Also is there any good example code that can let me know more about? Thanks!

Have a look at our tic-tac-toe template.