Difference between revisions of "Activate"
imported>Kkuhlmann |
imported>Tegid (Explained the explaination of Normal Flag and it's uses) |
||
Line 9: | Line 9: | ||
If ActivatorID is omitted, the Activate command will use the calling reference's "current activator". This is very useful inside of OnActivate blocks where you want the activation to proceed normally except under certain circumstances. | If ActivatorID is omitted, the Activate command will use the calling reference's "current activator". This is very useful inside of OnActivate blocks where you want the activation to proceed normally except under certain circumstances. | ||
'''That means that this:''' | |||
Activate | |||
'''Is equivalent to this:''' | |||
ref actingref | |||
set actingref to GetActionRef | |||
Activate actingref | |||
If ActivatorID is included, the calling reference will perform its default activation as if activated by ActivatorID. | If ActivatorID is included, the calling reference will perform its default activation as if activated by ActivatorID. | ||
Line 35: | Line 45: | ||
If NormalActivationFlag is omitted, the calling reference performs its default activation, bypassing any OnActivate script that might be on it. This is | If NormalActivationFlag is omitted, the calling reference performs its default activation, bypassing any OnActivate script that might be on it. This is often how you want to use Activate, since most times you are calling Activate on the object itself from inside an OnActivate block after performing some check or other action. | ||
If the NormalActivationFlag is 1, the calling reference will not bypass any OnActivate script on it. This flag basically is an override of default activation as represented in the above chart. Use this with care -- if you call Activate on the object itself from inside an OnActivate block you will trigger an infinite loop. | |||
When used with care, this can be an extremely powerful tool to cause activates to be used as pseudo function calls between scripted objects and even spells. The reference passed in can be used as arguments to tell the object being activated what to do. This use of Activate is not as intended and requires very careful planning and execution. | |||
'''Example 1:''' | '''Example 1:''' |
Revision as of 20:17, 16 April 2006
Syntax:
Activate ActivatorID (optional), NormalActivationFlag (optional)
Example:
Activate player Activate Activate player, 1
This function tells the object to perform its default activation.
If ActivatorID is omitted, the Activate command will use the calling reference's "current activator". This is very useful inside of OnActivate blocks where you want the activation to proceed normally except under certain circumstances.
That means that this:
Activate
Is equivalent to this:
ref actingref set actingref to GetActionRef Activate actingref
If ActivatorID is included, the calling reference will perform its default activation as if activated by ActivatorID.
Object Type | Activation |
---|---|
NPC | Dialogue |
Container | Opens |
Door | Opens |
Weapon, armor, etc | Picks Up |
Book/Scroll | Reads |
If NormalActivationFlag is omitted, the calling reference performs its default activation, bypassing any OnActivate script that might be on it. This is often how you want to use Activate, since most times you are calling Activate on the object itself from inside an OnActivate block after performing some check or other action.
If the NormalActivationFlag is 1, the calling reference will not bypass any OnActivate script on it. This flag basically is an override of default activation as represented in the above chart. Use this with care -- if you call Activate on the object itself from inside an OnActivate block you will trigger an infinite loop.
When used with care, this can be an extremely powerful tool to cause activates to be used as pseudo function calls between scripted objects and even spells. The reference passed in can be used as arguments to tell the object being activated what to do. This use of Activate is not as intended and requires very careful planning and execution.
Example 1:
If you call this script on a door, the door will behave as if the player had activated it (i.e. if a load door, the player will be teleported to the door's target location).
Activate player
Example 2:
Whatever triggered the OnActivate block will also Activate, just as if this script wasn't here.
begin OnActivate if MyCrazyCondition == 1 Activate else ; do something else endif end
Example 3:
This script will trigger an infinite loop -- once the scripted object is activated the OnActivate block will continue to be run forever.
float infinity begin OnActivate ; you should NEVER do this!! set infinity to infinity + .1 message "Infinity = %.1f", infinity activate player 1 end
Example 4:
This is the proper way to use the NormalActivationFlag
begin OnActivate ; trigger some other reference when I am activated by the player if IsActionRef player == 1 MyGate.Activate player 1 endif end