Difference between revisions of "Talk:Minimizing your Script"

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search
imported>DragoonWraith
imported>DragoonWraith
Line 14: Line 14:
: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.
: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.
:[[User:DragoonWraith|<span style="font-family: Oblivion, Daedric Runes; size=2;">D</span>ragoon <span style="font-family: Oblivion, Daedric Runes; size=2;">W</span>raith]] [[User_talk:DragoonWraith|<span style="font-family: Oblivion, Daedric Runes; size=2;">TALK</span>]] 19:50, 7 May 2009 (EDT)
:[[User:DragoonWraith|<span style="font-family: Oblivion, Daedric Runes; size=2;">D</span>ragoon <span style="font-family: Oblivion, Daedric Runes; size=2;">W</span>raith]] [[User_talk:DragoonWraith|<span style="font-family: Oblivion, Daedric Runes; size=2;">TALK</span>]] 19:50, 7 May 2009 (EDT)
== Uncertainty ==
I'm not sure this article is a very good idea. The advice seems heavy-handed for the effect - it is '''very''' rare for scripts to have any performance issues at all. "Avoid a GameMode block at all costs"? No. In fact, there are a number of reasons to use a GameMode block even when another block would work - OnEquip comes to mind ''immediately'' as an excellent situation where using a GameMode block with a conditional is '''much''' better than using the specific block (since OnEquip does not work for items that are equipped with EquipItem). Giving this kind of advice without much better advice on ''why'' you should or shouldn't do certain things strikes me as unwise. It's only going to confuse people, like Cbh up there.<br />
[[User:DragoonWraith|<span style="font-family: Oblivion, Daedric Runes; size=2;">D</span>ragoon <span style="font-family: Oblivion, Daedric Runes; size=2;">W</span>raith]] [[User_talk:DragoonWraith|<span style="font-family: Oblivion, Daedric Runes; size=2;">TALK</span>]] 19:53, 7 May 2009 (EDT)

Revision as of 18:53, 7 May 2009

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)

Uncertainty

I'm not sure this article is a very good idea. The advice seems heavy-handed for the effect - it is very rare for scripts to have any performance issues at all. "Avoid a GameMode block at all costs"? No. In fact, there are a number of reasons to use a GameMode block even when another block would work - OnEquip comes to mind immediately as an excellent situation where using a GameMode block with a conditional is much better than using the specific block (since OnEquip does not work for items that are equipped with EquipItem). Giving this kind of advice without much better advice on why you should or shouldn't do certain things strikes me as unwise. It's only going to confuse people, like Cbh up there.
Dragoon Wraith TALK 19:53, 7 May 2009 (EDT)