How do I look for value in a specific column in the array?

0 favourites
  • 10 posts
From the Asset Store
Supports 1D, 2D, 3D arrays. Import and export arrays in JSON format
  • In the array below, I want to look for a certain value only in column Y1, I don't want it to look for that value in the entire array. Let's say I want the value 51, it's at (1,4) and also at (2,4) and still at (3,4). So I want the program to look only in column Y1. And when it finds the value, which in this case as an example I want the number 51, in the column that I want to be Y1, which is in (1,4), I want it to return the value of the y column on the side , that is y-1, that is, in this case it would be (0,4) or (1-1,4).

    If anyone can help me I would be grateful, thanks.

    Tagged:

  • You can start with a system 'for loop' to run through each row so from 0 to array.width. Then within that loop you compare X,Y of the array using array conditions, where X is loopindex and Y is 1. Then again add a sub event using array conditions to compare current value if = 51, then you can stop loop and grab the value from array.at(loopindex,0) which is the other column. Note that I'm talking in terms of (x,y) your post seems to describe the array in terms of (y,x)

  • Yeah, in Array.At(1,4) the first index is X and the second is Y. So it's X=1 and Y=4

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can start with a system 'for loop' to run through each row so from 0 to array.width. Then within that loop you compare X,Y of the array using array conditions, where X is loopindex and Y is 1. Then again add a sub event using array conditions to compare current value if = 51, then you can stop loop and grab the value from array.at(loopindex,0) which is the other column. Note that I'm talking in terms of (x,y) your post seems to describe the array in terms of (y,x)

    I understand the logic you're talking about, but some things are new to me, like this for each loop that I hardly used, and the array expressions, which, as much as I read the manual, it's just in practice. Could you describe the logical step by step? I'm trying to implement but I don't know how to do certain parts, even though you explained it well.

  • I'll make a file tomorrow need to sleep now

  • This is awesome, I came close with your previous explanation, but something was really missing. You helped me a lot, thank you. That was amazing, sorry to take your time with this. I will study your example deeply to fix this well....

  • No problem, I like when people are learning how to use arrays, they are great! :D

  • It is too bad when people create example files but they get deleted. :/

    lionz

  • Telyko what do you need help with? A new post is better as someone is always around to help anyway

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