Activate

From the CreationKit Wiki
Jump to navigation Jump to search

Syntax:

ObjectToActivateRef:rec.Activate [ActivatorID:rec] [RunOnActivateBlock:bin] 

(note on syntax: Italics = object that's acted on, Bold = function name, [Brackets] = optional field, "rec" = record, "bin" = binary. See discussion for more info)

Example:

Activate player 
ContainerRef.Activate 
ActivatorRef.Activate player, 1 

If the RunOnActivateBlock is set to zero (default) this function makes the object only perform its default activation, bypassing any OnActivate Block in its script.

The default activations for the player are:

Object Type Activation
NPC Dialogue
Container Opens
Door Opens
Weapon, armor, etc Picks Up
Book/Scroll Reads

For Enabled NPCs, activating an item will force them to pick it up (even if they're unconscious). However, containers won't pick up the item.

If the RunOnActivateFlag is set to 1, then the OnActivate block of the object (if any) will be run instead of the default activation. (In other words, act just as if ActivatorID activated it directly -- NPC used it, Player moused over and clicked on it, etc.)


If the ObjectToActivateRef flag isn't set then the object will activate itself (as with most functions). There are a couple of tricks you can pull with this:

  1. You can use Activate inside of an object's OnActivate block to make it also perform it's default activation
  2. You can use Activate player, 1 inside of an object's onActivate block to make it run it's OnActivate block again (see Nesting below)
  3. You can use Activate player, 1 to make an item activate itself while inside an inventory. By having the item continuously check a persistent variable, you can make external scripts "activate" the item by controlling the persistent variable.


The ActivatorID flag determines the ActionRef for that activation, as if the ActionRef had activated the object. This is useful if you use IsActionRef or GetActionRef inside of the OnActivate block of the object. If the ActivatorID flag is omitted, the calling reference's ActionRef will be used instead.

That means that this:

Activate

Is equivalent to this:

ref actingref
set actingref to GetActionRef
Activate actingref

If the calling reference doesn't have an ActionRef (for example, if the calling reference is a quest) then the object won't be activated and the line will be ignored (the calling reference's script will continue).

See Also[edit | edit source]

OnActivate

Papyrus Version[edit | edit source]

ObjectReference.Activate (Papyrus)