Talk:GetNthRef - Cell

From the CreationKit Wiki
Revision as of 07:11, 28 February 2015 by imported>Terra Nova2 (→‎Handling references without names)
Jump to navigation Jump to search

Handling references without names

This function as well as GetNumRefs - Cell doesn't take names in account when you're looking for a specific type. Furthermore, if you narrow down the amount in order to fit an array(not doing so will take the array out of bounds) it will also fill the array with forms that don't have a name, if you're trying to fill an array based on names.

For handling the ones without names.. do this:

Actor property PlayerRef auto

Cell kCell = PlayerRef.GetParentCell()
Int n
Int iRefs = kCell.GetNumRefs(38) ; trees

Function SomeFunction()
         While (n < iRefs)
                ObjectReference kRefs = kCell.GetNthRef(n, 38)
                if kRefs.GetBaseObject().GetName() ; by default, strings are true if they a not empty.
                     ; add to alias, array, etc. ONLY filled with references that have names!
                endif
                n += 1
         EndWhile
EndFunction

--Terra Nova2 (talk) 2015-02-28T07:11:07 (EST)