Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: Litow on April 14, 2018, 01:39:21 AM
-
Super newbie question.
Trying to collect the first index of the largest integer under an array.
How does one collect array values in the first place... ahahahah
I tried to copy a few options.
I cant get this to work no matter how i switch variable types around.
Or. How do you cast them??
EDIT: the code solution below as well...
private void DoGetIndex()
{
if (array.IsNone)
{
return;
}
currentIndex = 0;
tmpValue = 0;
finalIndex = currentIndex;
arrayLength = (int)array.Length;
if (arrayLength == 1)
{
index.Value = currentIndex;
}
else
{
while (currentIndex < arrayLength)
{
arrayValue = (int)array.Get(currentIndex);
if (arrayValue > tmpValue)
{
tmpValue = arrayValue;
finalIndex = currentIndex;
}
currentIndex++;
}
index.Value = finalIndex ;
}
}
-
Hi.
you could just make a loop :)
(https://i.imgur.com/HreubUB.gif)
-
I sure could... not sure why I didnt think about it.
Maybe I felt the urge to hurl myself into that wall.
Thank you!
EDIT:
And I ended up learning how to cast. So updated the question above as well, in case it helps anyone.