loop over table values

hi im having abit of trouble with loop over table. i cant seem to find much resources regarding looping threw the table with a string expression to find a cell in specific column that hasn't been changed. to make more sense, ive got a table with three columns and i need to loop threw the third column. one actor will loop threw and pick an item and after that it will change the state of the third cell in the third row from zero to one. i want another actor to when touch is pressed loop threw the table and bypass all third column cells with the value of one and choose the first with zero. i think im not correctly picking the second half of statement but as there isnt any documents that i can find i am needing a bit of help. thanks for any help.

Comments

it will change the state of the third cell in the third row from zero to one.

After you find a matching cell in column 3, what should happen next? What does "the third cell in the third row" refer to?

Sometimes, it's helpful to provide a screenshot of part of your table.

As for the second part... use a tableSearch function. It finds the first matching cell. So if you just need the first cell with a zero, do a tableSearch using zero as the key.

Keep in mind that whether you are looping through a table or using a tableSearch behavior, you will probably need to wrap them in a timer set to after 0 seconds with run to completion checked. Otherwise, when the touch is released (too soon), the loop/search will not have time to complete.

I will upload screenshots of table and the rules as they are now when I’m home. I have used the loop before but only to search specific cells, I am trying to search a specific column of cells. As the loop goes threw the cells of the column I want it to pick out the first cell with the value zero. This is my problem. I think my problem is the expression as I’m using a string expression within the loop

I understood what you wrote about searching for the first zero in a column. I thought that you were doing a separate loop/search as well but maybe I misunderstood. If all you need to do is find a zero among non-zero values, it's very easy*.

I've got the demo to work now. i had the if expressions wrong. i do however have another question. the loop over table function, do i have to add anything special for the loop to end after its found its table cell, i only ask as i will have other actors using this table and loop function.

Well, the Loop Over Table behavior runs from the Start Index cell to the End Index cell. So it won't stop when it finds a match. But -- huh -- what? I thought you just needed to find the first zero in a column, which would only require a tableSearch function, not a Loop.

I also think you're going to have unpredictable results running a Loop Over Table inside an every 0.03 seconds timer, especially with Run to Completion unchecked. Make sure you test that on an actual device... not just a PC running GameSalad.