Difference between revisions of "Talk:Arrays (Papyrus)"

538 bytes removed ,  09:43, 24 February 2015
m
→‎Avoiding "Array Index out of range": Changed this to something more accurate.
imported>Terra Nova2
imported>Terra Nova2
m (→‎Avoiding "Array Index out of range": Changed this to something more accurate.)
Line 258: Line 258:
= Avoiding "Array Index out of range" =
= Avoiding "Array Index out of range" =


Well, this was something I encountered a ton and there was very little information on how to avoid it besides getting it from the more common mistakes.


In my case, if you iterate an int that runs before the code for the array to run through its elements, it'll return the last element as being out of range.
This can occur if the number of references you're adding to an array at run-time exceeds the length of the array.
 
As an example
 
<source lang=papyrus>
i += 1
myArray[i].DoSomething()
</source>
 
Brings up the error. To avoid it, you switch their order. The confusing bit here is I've seen syntax like this used before but no one complains about the compiler. Hmm..--[[User:Terra Nova2|Terra Nova2]] ([[User talk:Terra Nova2|talk]]) 2014-11-03T06:27:44 (EST)
Anonymous user