Difference between revisions of "IsChild - Location"

From the CreationKit Wiki
Jump to navigation Jump to search
imported>Terra Nova2
(Added note about this function not exactly telling the truth about rather the calling location is the parent of the passed in location. As well link to my page regarding location hierarchies.)
imported>Lisselli
 
(4 intermediate revisions by 3 users not shown)
Line 22: Line 22:
   Debug.Trace("My house is a child of the Batooine location")
   Debug.Trace("My house is a child of the Batooine location")
endIf
endIf
</source>
<br>
<source lang="papyrus">
Bool Function HasLocation(Location akLocation, Location akOtherLocation)
; Does the same thing as ischild, but checks if the location is none.
if akLocation && akOtherLocation != none
if akLocation.isChild(akOtherLocation)
return true
else
return false
endif
else
return false
endif
EndFunction
</source>
</source>


== Notes ==  
== Notes ==  
* The majority of locations in the game have a hierarchy or nest of locations with TamrielLocation usually the last in this list. This function will return true even if the calling location is not the actual parent of the passed in location. In other words, if you call TamrielLocation on DawnstarLocation, it will return true, when the parent for DawnstarLocation is actually the PaleHoldLocation. And as all holds in the game have TamrielLocation as their parent location, it is concluded that this will return true for any location in the hierarchy, regardless if the calling location is not actual parent of the passed in Location.
* This function will return true if the TamrielLocation is the calling location, even though the Parent location set on the passed-in (akOther) location's form is not set to TamrielLocation. This is because this function checks whatever is the parent location of the parent location of the passed-in location. To better explain this: RiverwoodLocation's parent location is WhiterunHoldLocation, while WhiterunHoldLocation's parent is TamrielLocation. This function will return true for either of them for RiverwoodLocation. So, if you want to know if a particular is a parent, do not use Tamriel unless you really want to know if Tamriel is the parent.
 
== See Also ==
== See Also ==
*[[Location Script]]
*[[Location Script]]

Latest revision as of 07:40, 7 August 2017

Member of: Location Script

Returns if the other location is a child of this one. If they are the same location, the function returns false.

Syntax[edit | edit source]

bool Function IsChild(Location akOther) native

Parameters[edit | edit source]

  • akOther: The other location to look at.

Return Value[edit | edit source]

Returns if the other location is a child of this one.

Examples[edit | edit source]

; Is my house a child of the Batooine location?
if (BatooineProperty.IsChild(MyHouseProperty))
  Debug.Trace("My house is a child of the Batooine location")
endIf


Bool Function HasLocation(Location akLocation, Location akOtherLocation)
; Does the same thing as ischild, but checks if the location is none.
if akLocation && akOtherLocation != none
	if akLocation.isChild(akOtherLocation)
		return true
	else
		return false
	endif
else
	return false
endif

EndFunction

Notes[edit | edit source]

  • This function will return true if the TamrielLocation is the calling location, even though the Parent location set on the passed-in (akOther) location's form is not set to TamrielLocation. This is because this function checks whatever is the parent location of the parent location of the passed-in location. To better explain this: RiverwoodLocation's parent location is WhiterunHoldLocation, while WhiterunHoldLocation's parent is TamrielLocation. This function will return true for either of them for RiverwoodLocation. So, if you want to know if a particular is a parent, do not use Tamriel unless you really want to know if Tamriel is the parent.

See Also[edit | edit source]