Difference between revisions of "RFindStruct - Array"

From the Fallout4 CreationKit Wiki
Jump to navigation Jump to search
imported>Plplecuyer
m
 
imported>Qazaaq
(added category)
 
Line 1: Line 1:
[[Category:Scripting]]
'''Member of:''' [[:Category:Arrays| All Arrays]]
[[Category:Papyrus]]
'''Member of:''' All arrays


Locates a particular value in a struct inside an array and returns the index, starting from the end of the array, and moving to the beginning
Locates a particular value in a struct inside an array and returns the index, starting from the end of the array, and moving to the beginning
Line 37: Line 35:
*[[Find - Array]]
*[[Find - Array]]
*[[RFind - Array]]
*[[RFind - Array]]
[[Category:Scripting]]
[[Category:Papyrus]]
[[Category:Arrays]]

Latest revision as of 20:31, 1 March 2018

Member of: All Arrays

Locates a particular value in a struct inside an array and returns the index, starting from the end of the array, and moving to the beginning

Syntax[edit | edit source]

int Function RFindStruct(StructVarName asVarName, ;/var type/; akElement, int aiStartIndex = -1) native

Parameters[edit | edit source]

  • asVarName: The name of the struct variable to compare with
  • akElement: The element to locate
  • aiStartIndex: Where to start the search
    • Default: -1

Return Value[edit | edit source]

The index of the struct in the array with the matching value, or a negative value if it was not found.

Examples[edit | edit source]

if (MyPointArray.RFindStruct("X", 1) < 0)
  Debug.Trace("Did not find a point with an X of 1 in the array")
endIf


int firstPosition = MyPointArray.RFind("Y", 10)
Debug.Trace("Found the last point with an Y of 10 at position " + firstPosition)
int secondPosition = MyPointArray.RFind("Y", 10, firstPosition + 1)
Debug.Trace("Found the second last point with an Y of 10 at position " + secondPosition)

See Also[edit | edit source]