Faking object timer properties

Hey everyone,

I saw an interesting post in the support thread about setting timer properties, and so I set about trying to recreate them.
On their own, timer properties are nothing special; simply subtracting the creation time from the current time, but most of the ways of doing this would involve an interface. I set about trying to find a way to use them without such an interface, and the final solution involves some descriptor trickery.

The only thing that this timer cannot do, is to interface with preset properties directly. Because of the way the engine reads properties, we have to first set their value to an “interface” property. However, this shouldn’t be an issue, because if you wanted to interface with the Logic Bricks in the first place you wouldn’t be using this Python alternative to a timer.

simple_timer.blend (466 KB)

You simply need to patch the object. Then whenever you add a Timer instance, it will work as a timer. This assumes that you copy the import code and time_lib.py