Difference between revisions of "GetActorOwner - ObjectReference"
GetActorOwner - ObjectReference (edit)
Revision as of 18:01, 10 September 2015
, 18:01, 10 September 2015→Returning an inherited owner
imported>Rhavlovick m (1 revision: Clobber re-import by Henning) |
imported>Fireundubh |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 6: | Line 6: | ||
== Syntax == | == Syntax == | ||
<source lang="papyrus"> | <source lang="papyrus"> | ||
ActorBase Function GetActorOwner() native | ActorBase Function GetActorOwner() native | ||
Line 11: | Line 12: | ||
== Parameters == | == Parameters == | ||
None. | None. | ||
== Return Value == | == Return Value == | ||
The [[ActorBase Script|ActorBase]] that owns this object. | The [[ActorBase Script|ActorBase]] that owns this object. | ||
== Examples == | == Examples == | ||
=== Returning an explicit owner === | |||
<source lang="papyrus"> | <source lang="papyrus"> | ||
; Does the player own the sword? | ; Does the player own the sword? | ||
Bool playerOwnsSword = SwordProperty.GetActorOwner() == Game.GetPlayer().GetActorBase() | |||
</source> | </source> | ||
=== Returning an inherited owner === | |||
<source lang="papyrus"> | |||
; Does the player own the sword? | |||
Bool playerOwnsSword = GetInheritedOwner(SwordProperty, SwordRackProperty) == Game.GetPlayer().GetActorBase() | |||
ActorBase Function GetInheritedOwner(ObjectReference aObj, ObjectReference aContainer) | |||
ActorBase actorOwner | |||
; if the object exists | |||
; try to get the object's explicit owner | |||
If aObj | |||
actorOwner = aObj.GetActorOwner() | |||
; if the object does not have an explicit owner | |||
; and if the container exists | |||
; try to get the container's explicit owner | |||
If !actorOwner | |||
If aContainer | |||
actorOwner = aContainer.GetActorOwner() | |||
; but if the container also does not have an explicit owner | |||
; try to get the parent cell of the container's explicit owner | |||
If !actorOwner | |||
actorOwner = aContainer.GetParentCell().GetActorOwner() | |||
EndIf | |||
EndIf | |||
; if even the parent cell of the container does not have an explicit owner | |||
; try one last time to get the parent cell of the object's explicit owner | |||
If !actorOwner | |||
actorOwner = aObj.GetParentCell().GetActorOwner() | |||
EndIf | |||
EndIf | |||
EndIf | |||
; returns an explicit owner, inherited owner, or none | |||
Return actorOwner | |||
EndFunction | |||
</source> | |||
== Notes == | |||
=== Explicit vs. Inherited Ownership === | |||
Object references can have explicit owners and inherited owners. An ''explicit owner'' is associated directly with the object. An ''inherited owner'' is derived from the container that contains the object, the cell that contains the object, or the cell that contains the container that contains the object when the object has not been associated with an explicit owner. GetActorOwner() returns only the explicit owner of an object reference and None when an explicit owner is not found. | |||
== See Also == | == See Also == | ||
*[[ObjectReference Script]] | |||
*[[SetActorOwner - ObjectReference]] | * [[ObjectReference Script]] | ||
* [[SetActorOwner - ObjectReference]] |