Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest WME version: WME 1.9.1 (January 1st, 2010) - download

Author Topic: Infinite loop and performance  (Read 2559 times)

0 Members and 1 Guest are viewing this topic.

Birdline

  • Supporter
  • Occasional poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 57
    • View Profile
    • Birdline Web Site
Infinite loop and performance
« on: December 09, 2008, 02:53:17 PM »

I have a small script with a loop (infinite).
It just checks the health of the actor and ends the game.
It is some thing like this:
while(1)
{
if the actor's health is something
then the game is over
}
My question:
What is the difference in game performace in the following 2 cases?
Case 1: I attach/detach this script when ever I need it
Case 2: I attach this in game script so it is always running

Best regards,
Spyros

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Infinite loop and performance
« Reply #1 on: December 09, 2008, 03:04:56 PM »

It depends on how much stuff the script does in each iteration and how often (i.e. what's the Sleep value in the loop). Try to keep the sleep value as high as possible.
If you need to check the health most of the time, keep the script running. If you only need it from time to time (like e.g. only in some scenes), it may be more effecient to kill the script if it's not needed.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Birdline

  • Supporter
  • Occasional poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 57
    • View Profile
    • Birdline Web Site
Re: Infinite loop and performance
« Reply #2 on: December 09, 2008, 04:36:56 PM »

Mnemonic, thanks for the advise,
I don't really need it to run (most of the time), so I will attach/detach when ever needed.
I just wanted to know if there is big difference.

Best regards,
Spyros
 

Page created in 0.041 seconds with 20 queries.