Jump to content

[PSA] Break past the 128 elements array limit with SUP F4SE


niston

Recommended Posts

The infamous 128 elements limit for Papyrus arrays was added as a safety precaution. Which is probably a good thing, generally speaking.

But sometimes, you just gotta put more than 128 elements. Here's how:

	; use your own struct here
	Struct SomeStruct
		Int SomeInt
		Float Whatever
	EndStruct
    
    ; the array you want to add to
	SomeStruct[] myArray = new SomeStruct[0]	

	; your new element to add to myArray
	SomeStruct newElement = new SomeStruct
	
	; add new element to the array
	If (myArray.Length < 128)
		; regular add
		myArray.Add(newElement)
	Else
		; SUP based add past 128 limit
		SomeStruct[] newEntryArray = new SomeStruct[1]
		newEntryArray[0] = newElement		
		myArray = SUP_F4SE.MergeArrays(myArray as Var[], newEntryArray as Var[]) as SomeStruct[]
	EndIf

The example shown uses an array of Struct, but the principle works with any Papyrus array type.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...