Small Array IndexOf Question

Get help using Construct 2

Post » Fri Jun 14, 2013 8:19 pm

Does anyone know if there is any way to pass a variable to the Array.IndexOf() thingy?

If I had loads of UIDs or something similar loaded into an array and I wanted to find what it's X was, how do I do that? It looks like Array.IndexOf(Object.UID) doesn't work, the only time I can get a result out is if I specify the number in quotes i.e. Array.IndexOf("111"). This isn't of much use to me

I've tried looking through the other topics and can't find anything.
Posts: 14
Reputation: 403

Post » Fri Jun 14, 2013 9:51 pm

That's weird, maybe the UID got stored in string format somehow. Did you try checking if Array.IndexOf(str(Object.UID)) worked ?
Posts: 1,027
Reputation: 21,114

Post » Sat Jun 15, 2013 12:23 pm

That fixed it!

Thanks so much.

I swear I'd tried wrapping the variable reference in all sorts of int()/float()/string() string expressions and nothing worked. Must have been doing something stupid.

I know why the array has it as a string value. I have all of my data for my enemies load into an array from an xml. If I use xml.NumberValue I only get ints out and some of my data has decimals. To get round this I have them all stored in the array as strings.

Posts: 14
Reputation: 403

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 8 guests