Difference between revisions of "Talk:IsChild - Location"

From the CreationKit Wiki
Jump to navigation Jump to search
imported>Lisselli
m
imported>Lisselli
(Undo revision 48378 by Lisselli (talk))
 
Line 7: Line 7:
:: In other words, this function is not useful on its own if you want to find out which holdlocation is the parent location of a location. [[User:Lisselli|Lisselli]] ([[User talk:Lisselli|talk]]) 2017-04-23T08:02:37 (EDT)
:: In other words, this function is not useful on its own if you want to find out which holdlocation is the parent location of a location. [[User:Lisselli|Lisselli]] ([[User talk:Lisselli|talk]]) 2017-04-23T08:02:37 (EDT)
::: Correction: To check if a hold is the parent of a location or not, just call this function on a hold location property. [[User:Lisselli|Lisselli]] ([[User talk:Lisselli|talk]]) 2017-04-24T00:26:26 (EDT)
::: Correction: To check if a hold is the parent of a location or not, just call this function on a hold location property. [[User:Lisselli|Lisselli]] ([[User talk:Lisselli|talk]]) 2017-04-24T00:26:26 (EDT)
== GetRefLocation ==
<source lang="papyrus">
Bool Function GetRefLocation(ObjectReference akRef, Location akOtherLocation, Bool abSwap = False)
; Do not use TamrielLocation unless you want to know if it's the parent of a location.
; By default this function returns true or false if the akRef's location is a child of the passed in location.
; Set abSwap to true if you want to know if the ref's location is a parent of a location.
; Will return false if the current location is none.
Location akRefLocation
if abSwap == true
akRefLocation = akRef.GetCurrentLocation()
if akRefLocation == none
return false
endif
else
akRefLocation = akOtherLocation
akOtherLocation = akRef.GetCurrentLocation()
if akOtherLocation == none
return false
endif
endif
; Is the reference valid?
if akRef != none
; Are we in an exterior?
if akRef.IsInInterior() == true
if akRefLocation.isChild(akOtherLocation) == true
return true
else
return false
endif
else
if akRefLocation.isChild(akOtherLocation) == true
return true
else
return false
endif
endif
else
return false
endif
EndFunction
</source>

Latest revision as of 07:39, 7 August 2017

If you call this on Tamriel, it will always return true - unless the cell has no location, or that location's parent doesn't have Tamriel as the "final" parent, to which this function will return none. IsChild() doesn't check for locations between the caller and the passed in, if the caller is Tamriel. --Terra Nova2 (talk) 2016-02-05T09:24:07 (EST)

An example to this would be.. Riverwood has the location RiverwoodLocation. The parent location for its location form is WhiterunHoldLocation. However if you write this code:
TamrielLocation.isChild(RiverwoodLocation)

It will return true, even though it's actually WhiterunHoldLocation. Additional coding is needed if you want to get the true parent location of a location. Lisselli (talk) 2017-04-23T07:55:42 (EDT)

In other words, this function is not useful on its own if you want to find out which holdlocation is the parent location of a location. Lisselli (talk) 2017-04-23T08:02:37 (EDT)
Correction: To check if a hold is the parent of a location or not, just call this function on a hold location property. Lisselli (talk) 2017-04-24T00:26:26 (EDT)