Difference between revisions of "Minimizing your Script"

295 bytes added ,  12:54, 23 January 2010
m
Small change to eliminate confusion for new scripters.
imported>KyleWollaston
imported>XJDHDR
m (Small change to eliminate confusion for new scripters.)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
The following is only important when a script does a CPU intensive task that is known or has been tested to affect the frame rate.  This is generally reduced to situations that involve naive searching, sorting, or constant iteration through many references.  Code that must have inefficient algorithms can best take advantage of the techniques here.  Note that almost all code produced with the vanilla editor will already run well, regardless of programming technique.
== Gamemode Scripts ==
== Gamemode Scripts ==
Avoid using gamemode scripts wherever possible. Use quest scripts if you can, or try to find ways to put as much of the script work into OnLoad, OnEquip, and ScriptEffectStart blocks as possible.
Avoid using gamemode scripts wherever possible. Use quest scripts if you can, or try to find ways to put as much of the script work into OnLoad, OnEquip, and ScriptEffectStart blocks as possible.
Line 27: Line 29:


begin GameMode
begin GameMode
   if (some condition)
   if (some condition) != 0
     (some extremely long code block)
     (some inefficient/complex algorithm)
   endif
   endif
end</pre>
end</pre>
Line 41: Line 43:
   endif
   endif


   (some extremely long code block)
   (some inefficient/complex algorithm)
end</pre>
 
You can also do this:
 
<pre>;; optimized 2
 
begin GameMode
  if (some condition)
    if (some condition) == 0
      return
    endif
    (some extremely long code block)
  endif
end</pre>
end</pre>


Anonymous user