Background for Skyrim SE
Member of the ObjectReference script
voidfunctionAddKeyIfNeeded(ObjectReferenceObjectWithNeededKey)

Description

Wiki Description

Checks this object's inventory for a key used by the parameter ObjectWithNeededKey. If this object does not have the key, it creates it and adds it to its inventory.

Documentation String

Should only be called by ObjectReferences that have/are containers (ie Containers and Actors). Checks to see if self has the key to ObjectWithNeededKey, and if not, creates a copy of the key and puts it in self.

Documentation Comment

jduvall


Parameters

  1. ObjectReferenceObjectWithNeededKey

    CK Wiki Description

    The reference that is locked with a key. It will create a key to this object and add it to the calling object if the calling object doesn't already have one.


Examples

; Creates a key to BobsDoorRef and puts it in BobRef's inventory if BobRef doesn't already have that key in his inventory.
BobRef.AddKeyIfNeeded(BobsDoorRef)

Auto-Generated Example

ObjectReference myObjectReference__ObjectWithNeededKey

myObjectReference__toCallFunctionOn.AddKeyIfNeeded(myObjectReference__ObjectWithNeededKey)

Related Pages


Additional References

View this function’s page on the Skyrim Creation Kit Wiki

Some data provided by the Skyrim Creation Kit Wiki. Licensed under the Creative Commons Attribution-ShareAlike license.