Defold Timer - The native timer extension


I just tried adding the timer as a dependency and it works for me :confused:

Do you use any other extension? Could it be some trouble with that one?


I do not know. The original timer is saved, but the phone does not work. Project Exploere says that ext.manifest and timer.cpp can not be built.

So I used the timer module provided by britzl. I use it as a module and it works fine.


I’ve updated the extension to support that timers can cancel other timers in their callback functions. This did previously cause crashes in the extension (a typical case of iterating an array and removing elements at random).


I’ve tried to build your cool extension for windows and got an error: < sys/time.h > not found.


Btw, I noticed that NE’s Update function is called three times more often that GameObject’s one. Why?


Do you have fixed Delta Time setup in your game.project?


display.variable_dt = 1
I’ve tried to uncheck this flag and nothing changed.


Are you by any chance starting the engine on the device as a debug target? That “connection app” doesn’t share the Lua context, so it’s started once per Lua context (3 of them in the engine)
Or if you have the project setting script.shared_state = false you get the same thing.


Thank you! I’ve found, that the script.shared_state flag is false.


How can I find out the context of the call?


It’s the params->m_L (doc)


Yes, but how can I understand, that this context is for scripts, and this one is for graphics?


Good question.
I guess the easiest way is to check if the context contains either the go or render modules.


I’ve updated the extension to support Windows as well. Please give it a try and let me know if it’s working as expected.


Yes, it’s working!


Tried to build HTML5 version with timer but failed. Is there a way to use this extension with HTML5?


Oh, it doesn’t work on HTML5?! I took a look at the output and found that apparently I was missing an include (stdlib.h). I’ve added this and pushed a new version of the extension. Thanks for pointing this out!


Now everything seems fine. Thanks a lot!


Can’t build Android app:

macOS also:

Linux also, but Linux is not supported, right? Or not?


That’s not the timer extension issue, any extension fails with this error. That’s Defold’s bug in Editor 2. Use Editor 1 for now.