Run a script every X ms?

Started by
3 comments, last by Ezbez 17 years, 6 months ago
I'm working on using Python to script my game right now, and I'm considering an idea that I just had. Currently, I have an OnFrame script that is, well, run once every frame. However, I thought that perhaps having a frame that isn't run based on framerate, but instead run every X milliseconds (frames that don't take X milliseconds would leave LengthOfFrame % X milliseconds for the next frame to handle). It seems logical and that it would certainly make frame-rate independent events easier to use. Do you think that this would be worth the extra effort? If it is, what do you think would be a good X to use? Thanks in advanced.
Advertisement
I would actually take that a bit further and not execute any script code at all unless an event occurs. If you want to implement some sort of timer functionality into the script system, then handle all the timer logic in native code. This doesn't have to be a hard and fast rule, but depending on how much of your game logic you eventually put in script you want to cut down the amount of time you spend there early on, rather than making comprises in the logic itself later on. This also means you should try to keep your game logic as event-based as possible and minimize update-based functionality.
I agree with Zipster. Adding scripting to a host application seems easy enough, but needs to be carefully thought-out in order to be efficient, especially for large-scale applications.
http://blog.protonovus.com/
I misread the title to X-mas. WTF, a script every Christmas? :D
Every time you implement a singleton, God kills a kitten. Please, think of the kittens!
Quote:Original post by Zipster
I would actually take that a bit further and not execute any script code at all unless an event occurs. If you want to implement some sort of timer functionality into the script system, then handle all the timer logic in native code. This doesn't have to be a hard and fast rule, but depending on how much of your game logic you eventually put in script you want to cut down the amount of time you spend there early on, rather than making comprises in the logic itself later on. This also means you should try to keep your game logic as event-based as possible and minimize update-based functionality.


Hmm... I haven't quite understood how this is going to work. So, I'm going to come up with an example. Say, I've got a homing missle that is targetting the player. How would that work in an event-based system?

FYI, every year my family and I get together and all run a big Christmas script while singing carols. ;)

This topic is closed to new replies.

Advertisement