===
1)
What I found really interesting (and useful) is that activations seem to be buffered. Maybe this is known, but I haven't seen it documented anywhere.
My script is rather long, but here's a simplified example of what happened:
set timer to ( timer + 1 ) ;if ( timer >= 256 ) set timer to 0 ;endifif ( timer == 0 ) ;.. ;.. ;.. ;This only runs once every 256 frames. Yet it works reliably. if ( "indrele rathryon"->OnActivate == 1 ) If ( act_ir == 151 ) ;currently sleeping messagebox, "This person is asleep" else "indrele rathryon"->Activate endif endif
Even though my script was only testing this every 256 frames, it still worked every single time. There was a noticeable lag of several seconds between hitting spacebar and seeing the dialog box pop up, but it always worked. Of course the lag I allowed here is too long, but the point is, you don't have to test OnActivate every single frame.
The following from MSFD pg 66 is apparently incorrect:
OnActivate
If ( OnActivate == 1 )
This gets set to one for one frame when the object is activated. OnActivate resets itself as soon as the function is called, so only one script can report OnActivate successfully,
If ( OnActivate == 1 )
This gets set to one for one frame when the object is activated. OnActivate resets itself as soon as the function is called, so only one script can report OnActivate successfully,
The 2nd sentence is correct, but the first is apparently incorrect. The game apparently holds OnActivate==1 indefinitely until your script reads it. This is convenient.
=================================
2)
The 2nd item I noticed is something that might be well-known, depending if this qualifies as a "targeted script". But mine was just a standard global script:
if ( act_ir = 151 ) ;currently sleeping if ( "indrele rathryon"->OnActivate == 1 ) ;once this is first called, the game no longer handles ANY activations of this object. messagebox, "This person is asleep" endif
The above broke auto-activation. Initially, activation worked fine. But after the if() test becomes true, and the OnActivate test first runs, then auto-activation of this object permanently dies.
Even after if ( act_ir = 151 ) is no longer true, you still can't activate indrele rathryon anymore.
This seems to be consistent with the documented problem with targeted scripts on pg171:
If OnActivate is used in a targeted script, the object will not be able to be activated by normal means after the script is stopped, unless a targeted script with OnActivate is again added to the object.
However, in my case, the script is still running, but it just isn't checking OnActivate anymore. That might be what the author meant. But the other point is that this isn't really a targeted script, unless I've misunderstood the definition. It's just a regular global script which uses a qualifier on the OnActivate test. So it seems the issue probably applies to any script, not just a targeted one.
Once you call OnActivate, the game expects you to handle all future activations of that object and will begin buffering (OnActivate == 1) until you read the value.
I might be nitpicking on the 2nd item, but thought it worth mentioning. The first item, regarding how it seems to buffer the OnActivate status, is quite useful though.