The trick is to isolate the various checks and functions into sections, using variable conditions, so that the section only runs when you need it to.
Further to this, to provide the absolute minimum overhead of a script you can put in a checkpoint to return immediately if none of the conditions you want to trigger the script are met. For eg:
Begin GameMode if Trigger return else if ; your usual conditions ; doing stuff ; doing stuff elseif ; some other stuff ; some other stuff endif if ; all conditions met set Trigger to 1 endif endifEnd
Once this script's conditions are met, it won't run again and will always immediately return. If you need it to run sometimes, but return early other times, simply change how you're checking for your trigger. For eg, an OnAdd block in the same script could change the value of Trigger, or perhaps the trigger is simply a timer check that returns until the timer is up etc.
The only thing to remember with a return is that everything after the script isn't parsed. This is of course why it helps script efficiencies, but it means if you have other code blocks that you want to run on other conditions (for eg Begin OnActivate) that may true while your trigger to return is true, then you need to move these codeblocks above the GameMode block in your script.
When you use Quest scripts you can control how often they run - default is every five seconds - which lets you adjust them for what you have to do. You can also start and stop them, so they only run when you need them. It's still a good idea to guard your code in these scripts so when the Gamemode and menumode blocks run, only the code you want to run, will run.
Yes, this is a very good point that a lot of people seem to forget. How often does your script
really need to run? If even the default 5 seconds isn't necessary, raise it. The main quest script in MMM that tracks various variables only runs once every 15 seconds.
While it's true script overhead is, generally, small (Cipscis did some great tests on this) my philosophy is don't add any overhead if you don't need to.