Difference between revisions of "Script Processing"

531 bytes added ,  18:19, 7 March 2009
no edit summary
imported>Kkuhlmann
imported>Wrye
Line 1: Line 1:
== '''How often scripts are processed:''' ==
== How Often are Scripts Processed? ==
*[[Quest scripts]]: processed every 5 seconds (by default) when the quest is running. You can change how often quest scripts are processed by changing a default variable in the quest's script.
;Actors (Creatures and NPCs): Processed every time the actor's AI is processed. In high process (the loaded area around the player), this is every frame. When the actor is not in high, this is much less often (down to once every 15 minutes of game time at the lowest process level). But these are still the only scripts (aside from quest scripts) that are processed when the player is not around.
*Scripts on actors (Creatures and NPCs): processed every time the actor's AI is processed. In high process (the loaded area around the player), this is every frame. When the actor is not in high, this is much less often (down to once every 15 minutes of game time at the lowest process level). But these are still the only scripts (aside from quest scripts) that are processed when the player is not around.
;Doors: A bit of a special case, these scripts are processed like other scripts on references (every frame when loaded), but they will also be processed once any time an actor activates the door.
*Scripts on references: processed every frame when its cell is loaded, not at all when the cell is not loaded. So these scripts run only when the player is nearby (which means these are often a good place to put relatively expensive scripts, doing things like distance checks).
;Objects in Containers: Processed when the container's script is processed -- so, items on actors are processed when the actor is processed; items in other containers are processed every frame when the cell is loaded.
*Scripts on objects in containers: these are processed when the container's script is processed -- so, items on actors are processed when the actor is processed; items in other containers are processed every frame when the cell is loaded.
;[[Quest scripts|Quests]]: Processed every 5 seconds (by default) when the quest is running. You can change how often quest scripts are processed by changing a default variable in the quest's script.
*Scripts on doors: a bit of a special case, these scripts are processed like other scripts on references (every frame when loaded), but they will also be processed once any time an actor activates the door.
;References: Processed every frame when its cell is loaded, not at all when the cell is not loaded. So these scripts run only when the player is nearby (which means these are often a good place to put relatively expensive scripts, doing things like distance checks).


== Remote Ref Heartbeat ==
Whenever a local variable on a persistent ref is set, the script of that reference will run for at least one frame after the setting. This means that if, in that one frame, the reference script again sets a variable, then the process is self continuing.
On the positive side, this means that it's possible to make a remote reference act as if is in scope for a prolonged period of time -- which is useful for remote containers. On the negative side, always in scope references will of course be a performance drain and should not happen unless necessary.


[[Category:Scripting]]
[[Category:Scripting]]
Anonymous user