Difference between revisions of "OnActivate"
Jump to navigation
Jump to search
imported>Elim Garak |
imported>Elim Garak |
||
Line 19: | Line 19: | ||
*Locked doors, containers and books are activated a second time automatically when you open the lock or take the book. To find out when a door was unlocked, for example, you can wait for '''[[GetLocked]] == 0''' in the OnActivate-block. | *Locked doors, containers and books are activated a second time automatically when you open the lock or take the book. To find out when a door was unlocked, for example, you can wait for '''[[GetLocked]] == 0''' in the OnActivate-block. | ||
*Reading a Book in the world will fire OnActivate, but reading it in the inventory will | *Reading a Book in the world will fire OnActivate, but reading it in the inventory will not. | ||
==See Also== | ==See Also== |
Revision as of 17:33, 23 September 2007
Syntax:
begin OnActivate
This block will be run once when the scripted reference is activated.
Notes:
- Using OnActivate will prevent normal activation of the object. To use the object's default activation you must call Activate on it.
- If you want to do something specific depending on what activated the object, use IsActionRef or GetActionRef inside the OnActivate block. They won't return the correct ActionRef in any other block.
- This block (and perhaps the entire script --Haama 18:52, 13 July 2007 (EDT)) runs immediately when called from an external script. There were a few things that were posted before that this should clarify:
- Activation occurs before the next line of code of the calling script is processed, and not in the next frame
- Any number of objects can activate one object, within one frame, and they will all be run (though see notes on Nesting)
- It's possible to nest activations. However, you can only have 5-6 nests at any given time (see Nesting for more information)
- The activator type of object has NO default activation.
- Locked doors, containers and books are activated a second time automatically when you open the lock or take the book. To find out when a door was unlocked, for example, you can wait for GetLocked == 0 in the OnActivate-block.
- Reading a Book in the world will fire OnActivate, but reading it in the inventory will not.