Hundreds of features to explore
Games made in Construct
Your questions answered
Popular & trusted by schools and Universities world-wide
Construct 3 runs in the browser & works offline
Students do not need accounts with us
Free education resources to use in the classroom
World class complete documentation
Official and community submitted guides
Learn and share with other game developers
Upload and play games from the Construct community
Game development stories & opinions
How do I loop through an array and stop looping if a value compared of a cell is equal?
if cell in x is equal to `foo`
Here is what I have got so far.
Hi guys, I have uploaded a CAPX with what I am trying to do. I am wondering if there is something case in construct where you can exit out of a loop when a condition is met. Ultimately I want a Plants vs Zombies tower selection mode.
Develop games in your browser. Powerful, performant & highly capable.
[quote:1j91tc3q]Loops can be stopped with the Stop Loop system action.
Not only in a array loop but any loop you can set a value in a variable ON/OFF where you just get inside of a loop when it's value is "1" and then reset (inside the loop in a sub event if necessary) to 0, then the loop won't run again.
Thanks for the responses Blackhornet and kossglobal!! much appreciated attacking this problem now.
Thanks again for the help guys.
I am having trouble populating array 1 with the contents of array 2. I am not sure what I am doing incorrectly. Could you peek into my capx? It sounds simple enough but it functions not.
You've got a bunch of stuff disabled. Can you get it back to a usable state so I'm not guessing what should or shouldn't be enabled.
Sorry about that black hornet. I have a new capx up there now. I fiddled around and have it populating array1 with the contents of array 2 but it populates all cells. I just want it to stop once it fills an empty slot.
I was fiddling some more and I think I fixed it!!! hurray doing some more testing to see if I can break it. Its all in the aove capx link