I'm having an issue where at the start of my layout I fill my array with 1's. Then after that, I go in and add some 2's to the array. However, whenever I try to set a global variable to the first X Index of 2 it always returns -1, meaning there is no 2 in the array even though there plainly is. I even set it up so that the code literally says
Array Contains Value 2 -> Set TestVar to Array.IndexOf(2)
And the TestVar returns -1 everytime, how is this possible?
https://drive.google.com/open?id=0BzhJb ... 3hYVXBZNjg
Thanks for any help that can be provided
Your function is never executed, because loopindex is always =0
I suggest you add a large text field to your layout and use it for debugging.
Try for yourself:
DebugText->Append text "Loopindex:" & loopindex
Develop games in your browser. Powerful, performant & highly capable.
You are correct, oversight on my part. I fixed the function not running and yet TestVar returns -1. I even double checked the array in debug mode and visually saw it contained the value 2.
I think IndexOf() only works with 1D arrays, as it can't return two values for X and Y axes.
Array->Contains value can tell you if this value exists, but to find its coordinates in 2D array you need to loop through it using "For each XY".