playMaker
Home
Store
Showcase
Tutorials
Forums
Manual
Wiki
About Us
Playmaker Forum
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email
?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News:
Join our
Discord Channel
Home
Help
Search
Login
Register
Playmaker Forum
»
PlayMaker Help & Tips
»
PlayMaker Help
(Moderator:
600
) »
SOLVED Get array value as an integer
« previous
next »
Print
Pages: [
1
]
Go Down
Author
Topic: SOLVED Get array value as an integer (Read 1365 times)
Litow
Playmaker Newbie
Posts: 26
SOLVED Get array value as an integer
«
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 ;
}
}
«
Last Edit: April 14, 2018, 05:45:18 PM by Litow
»
Logged
djaydino
Administrator
Hero Member
Posts: 7619
Re: Get array value as an integer
«
Reply #1 on:
April 14, 2018, 03:00:01 PM »
Hi.
you could just make a loop
Logged
Join the PlayMaker Discord Channel!
Litow
Playmaker Newbie
Posts: 26
Re: Get array value as an integer
«
Reply #2 on:
April 14, 2018, 05:09:22 PM »
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.
«
Last Edit: April 14, 2018, 05:21:52 PM by Litow
»
Logged
Print
Pages: [
1
]
Go Up
« previous
next »
Playmaker Forum
»
PlayMaker Help & Tips
»
PlayMaker Help
(Moderator:
600
) »
SOLVED Get array value as an integer