Hi Skylark and welcome to Evennia!
We're already discussing this in chat, but thought I'd answer here for completion (and for others looking)
There is really very little point in having a Script update with faster than a 1 second interval. If you can, try to do things on-demand instead, such as counting the time since last event. Try to never have something tick pointlessly if you can avoid it.
That said, src.utils.utils.delay is a thin wrapper around a twisted CallLater, and that
does handle sub-second intervals. Its use is described quite verbosely here:
http://code.google.com/p/evennia/wiki/CommandDuration.
Griatch
On Sunday, May 12, 2013 11:08:40 PM UTC+2, Skylark wrote:
After reading through the Evennia documentation I was unable to find anything that supported timing events with better resolution than one second. This is necessary for many aspects of a MUD I'm considering using Evennia to build, from position updates to regaining balance. Unfortunately, a script's interval must be an integer, and it didn't look like the delay utility for commands was the answer.
I'm a fairly inexperienced coder and didn't want to dive in without touching base. My first thought would be to use the heapq algorithm in Python's standard library (a minheap, fortunately) to create a timer engine. Items would be added to the heap with two values, a time of execution and a callback. A while loop would check the current time against the top priority item in the heap. If the current time is larger than or equal to the execution time, it would pop the element and run its callback. This repeats until no more items are scheduled to be run, at which point it yields.
Does this seem like a reasonable approach? Is there a better way to handle this you'd recommend? Where should the loop be called from? Any suggestions or help that can be offered would be extremely welcome.
Thanks for your time.