Difference between revisions of "Script Processing"

251 bytes added ,  19:50, 7 March 2009
imported>Wrye
imported>Wrye
Line 7: Line 7:


== Remote Ref Heartbeat ==
== 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.  
Whenever a local variable on a persistent ref is set, the script of that reference will be run in the next frame. Hence if a script continually sets a variable on itself, then it will continue to run every in every frame.  


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.
;Positive: This can be used to effectively keep a remote reference in "high processing". E.g. if items are stored in a remote container, then ordinarily the OnDrop and OnUnequip blocks of those items will not be run since the container is not local, and thus not in high processing. But by "heartbeating" he remote container ref, the item blocks can be made to run.
;Negative: Unintentional heartbeating of remote references will keep them permanently in high processing and thus hurt performance. Modders should ensure that script for persistent refs do not set a variable in every frame. (Be careful of this particularly in gameMode blocks, which are occasionally run even for out of scope persistent references.)


Unanswered Questions:
Notes/Questions:
* Does this work for non-persistent objects? (I think not.)
* This does not appear for non-persistent refs.
* Does the heartbeat survive cell transitions and reloads?  
* How about actors with no low level processing?
** Keep in mind that if the heartbeat doesn't run during a frame (e.g. during menuMode), it should die.


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