Small Array IndexOf Question

  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • That's weird, maybe the UID got stored in string format somehow. Did you try checking if Array.IndexOf(str(Object.UID)) worked ?

  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)