Difference between revisions of "GetNthRef - Cell"

From the CreationKit Wiki
Jump to navigation Jump to search
imported>PurpleLunchbox
(Created page with "Category:Scripting Category:Papyrus Category:SKSE '''SKSE Member of:''' Cell Script Returns the ObjectReference at the Nth index in the Cell based on the Form...")
 
imported>JustinOther
(→‎Examples: Reworked example (kCell.CellFunction() vs. Cell.CellFunction()))
Line 23: Line 23:


== Examples ==
== Examples ==
<source lang="papyrus">
<source lang="papyrus">Function PickEveryFlowerInCell(Actor akFlowerPicker) Global
int numFlora = Cell.GetNumRefs(39) ; kFlora = 39
Cell kCell = akFlowerPicker.GetParentCell()
int index = 0
Int iIndex = kCell.GetNumRefs(39) ; kFlora = 39
While index < numFlora
While iIndex
ObjectReference objRef = Cell.GetNthRef(index, 39)
iIndex -= 1
Debug.Trace("Flora Found in cell: " + objRef)
kCell.GetNthRef(iIndex, 39).Activate(akFlowerPicker)
index += 1
EndWhile
EndWhile
EndFunction</source>
</source>


== See Also ==
== See Also ==

Revision as of 08:51, 22 January 2013

SKSE Member of: Cell Script

Returns the ObjectReference at the Nth index in the Cell based on the FormType filter. (This function requires SKSE)

Syntax

ObjectReference Function GetNthRef(int n, int formTypeFilter = 0)

Parameters

  • n: The index at which the ObjectReference is located in the Cell with respect to the FormType filter.
  • formTypeFilter: Filters the list of which ObjectReferences are able to be retrieved, see GetType - Form for a list of FormTypes.

Return Value

Returns the ObjectReferences in the Cell at the Nth index based on the FormType filter.

Notes

  • Using a filter type of zero results in returning all object references in the cell.
  • If using a filter type make sure to use the same filter when determining the maximum amount.

Examples

Function PickEveryFlowerInCell(Actor akFlowerPicker) Global
	Cell kCell = akFlowerPicker.GetParentCell()
	Int iIndex = kCell.GetNumRefs(39) ; kFlora = 39
	While iIndex
		iIndex -= 1
		kCell.GetNthRef(iIndex, 39).Activate(akFlowerPicker)
	EndWhile
EndFunction

See Also