array.IndexOf(first.value.only) ?? left("",1)

0 favourites
  • 8 posts
  • How would I return an IndexOf trying to match only the first value per cell?

    I am hoping to organize like this:













    The first number is the Act, second number the Scene...

    I've been trying to use Left(,) but I can't get it to work.

    To pull Act 2 I've tried:


    doesn't seem right.


    also doesn't seem to work.

    I know I could bubble-process this but it seems there should be an easier way to write this.

    Currently I am doing this:



         If: left(array.At(array.CurX), 1)) = 1 then StopLoop and DoThis

         If: left(array.At(array.CurX), 1)) = 2 then StopLoop and DoThis

    etc, etc... Maybe this is the best way to do this? Except that its not really working either. I am getting the last value that matches not the first...

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • To find the first index of act 2, would be IndexOf(act*10+1). So for act=2, IndexOf(2*10+1), which is IndexOf(21). IndexOf(31)-1 would be the last act 2 index.

  • Well that makes perfect sense... and totally fixes that issue... But I can't do the same thing to my other array with text...

    I am getting the last value of A names, not the first...<img src="" border="0" />

  • "Stop loop" is a System action, not an Array action! It won't work. I vaguely remember someone requesting an "Array.Stop loop" action. Use the System.For mechanism instead, to index into the Array.

  • Hmmm OK I think I can work that out... makes sense that the Loop Stop is system and has no effect on the array action. Array.StopLoop would be nice!

    Thanks for taking a look!

  • <img src="" border="0" />

    Fixed!! Thanks a lot for both solutions! My project is working much much better now.

  • You should have 0 to Width-1. IE: For an array with width of 10, the indices are 0 to 9!

  • Thanks for catching that! It would have been obvious once I put this through its full test but now I won't have to face-palm later!

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