Difference between revisions of "ResizeIntArray - Utility"

From the CreationKit Wiki
Jump to navigation Jump to search
Line 27: Line 27:
</source>
</source>


== See Also ==
== Notes ==
* No need to actually create an array with '''''new''''', declaring an array variable is enough.
* No need to actually create an array with '''''new''''', declaring an array variable is enough.


== See Also ==
== See Also ==
*[[Utility Script]]
*[[Utility Script]]

Revision as of 17:44, 12 July 2023

Member of: Utility Script

Resizes an already existing array of Int values to the specified length.
Be careful when using this function. It is possible to create arrays longer than 128 elements, and size is treated as an unsigned integer. Negative numbers will produce extremely large values, which can cause major issues.

Syntax

int[] Function ResizeIntArray(int[] source, int size, int fill = 0) global native

Parameters

  • source: an existing array of int values.
  • size: new size of the array.
  • fill: a value to fill the array with.

Return Value

An Int array of size length. All elements of the array will be 0 or whatever number is specified as fill.

Examples

; let's make array length equal to available perk points, and fill all elements with 9

int[] pointsArray
pointsArray = Utility.ResizeIntArray(pointsArray, Game.GetPerkPoints(), 9)

Notes

  • No need to actually create an array with new, declaring an array variable is enough.

See Also