Talk:Minimizing your Script
I just added something re: script optimization that we knew from Morrowind scripting - it looks like Haama determined that the same thing is true for Oblivion in November '07 (good on you mate). The thread linked at the bottom of the page contains performance data that proves the same is true for Oblivion. --Halo112358talk 03:50, 30 May 2008 (EDT)
Potential early return problem
I'll start off by pointing out that I'm a relative scripting newbie, so take this with a pinch of salt!
Based on my observations (or perhaps trying to track down various "it doesn't quite work properly" bugs in my code), it would appear that the early return recommended in the gamemode block doesn't only cancel further execution of that block but the entire script: it seems that once return has been called, any subsequent blocks you might expect to run in addition to gamemode, for example "begin onpackagestart", won't.
Somebody with more experience may wish to confirm or deny this (though if the latter, an explanation for what I'm seeing would be helpful!) but it does seem at face value to be an important caveat to bear in mind. --cbh 13:41, 7 May 2009 (EDT)
- Well, that's what the Return function is meant to do - Prevent the iteration of the script for the rest of the frame. You can absolve some part of this by placing the gameMode/menuMode block at the end of the script.
- shadeMe TALK 16:57, 7 May 2009 (EDT)
- Yes, Return stops a script from running entirely on the frame on which it is caused. It should only be used when you do not want to run the script at all anymore on that frame. It does improve performance, but only marginally, and this is rarely a major concern for scripts.
- Dragoon Wraith TALK 19:50, 7 May 2009 (EDT)