Need help:what's the different between Wait() and OnUpdate()

Post » Mon Jan 12, 2015 9:58 am

If I want to call my main function in 2 sec, I can use Utility.Wait(2) in a while loop, or RegisterForSingleUpdate(2.0) for OnUpdate(), which one is better?

Thank you for your help!

User avatar
teeny
 
Posts: 3423
Joined: Sun Feb 25, 2007 1:51 am

Post » Mon Jan 12, 2015 9:30 am

Do you want to call your main function every two seconds, or call it once after a delay of two seconds?

For the first, use RegisterForSingleUpdate(2.0) once in your initialising function, with another RegisterForSingleUpdate(2.0) in your OnUpdate block.

For the second just use Wait(2.0) in your initialising function - no need to have it in a while loop.

If at all possible, avoid using RegisterForUpdate unless you absolutely must have your OnUpdate called at precisely 2 second intervals, and you know there will be enough CPU time to handle every call, and you know people will never uninstal your mod and then try to carry on with the same savegame. Ok, that last one isn't such a major point, I understand, but it's still best practice to avoid using RegisterForUpdate if you can avoid it.

User avatar
Rodney C
 
Posts: 3520
Joined: Sat Aug 18, 2007 12:54 am


Return to V - Skyrim