How do I do something in a For Loop only if True?

Get help using Construct 2

Post » Fri Dec 05, 2014 1:24 am

I'm uncertain how to write this in Construct 2. I'm attempting to assess a 2D array. One column is a value name for a location check while the other is a boolean switch. I'm trying to run through the array and if the switch is true, append the name value of the boolean to a text variable. Here's what I got:

Array proximity
Sprite player
Local text string = ""
Local number i = 0

For "" from 0 to proximity.Width, add 1 to i
-->proximity Value at (i,1) = 1, Set String & proximity.At(i,0)

If i >= proximity.Width, then set player.proximity to string


Some sample values within the array:
Wall,1
Floor,1
Ceiling,0
Ledge,0

Expected output: player.proximity=WallFloor

I can append the string if I have everything on the for loop and get every name value, but I can't seem to figure out how to add conditions within it to just get name values that are true.
B
6
S
2
Posts: 21
Reputation: 494

Post » Fri Dec 05, 2014 8:36 pm

Ha, okay. I'm just an idiot. That IS the right code. On start of layout without any user input, all switches were set to 0, hence no output. It's amazing what sleep and fresh eyes can do.
B
6
S
2
Posts: 21
Reputation: 494


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 7 guests