How can I check if a whole array width is 1?

Get help using Construct 2

Post » Fri Nov 16, 2012 6:57 pm

Hello. Using an array, what conditions should I use to check if all the values of the width are equal to 1?

For instance, I have an array of Width: 5, and I need a condition that does something when all the 5 cells of the width contain the value 1.

Another way it could work is if there was a way of adding up the values, so if all the values in the X of the array equal 5, then do something. That would also work for me. I would prefer this way actually. Thanks.
B
74
S
28
G
17
Posts: 256
Reputation: 15,125

Post » Fri Nov 16, 2012 7:02 pm

You could try Array.Contains value and invert the event.
So it could read as "if the Array does not contain 0"
Could something like that work?
B
12
S
5
G
2
Posts: 59
Reputation: 3,859

Post » Fri Nov 16, 2012 7:23 pm

Nice Idea ! David !
B
42
S
17
G
17
Posts: 2,247
Reputation: 17,461

Post » Fri Nov 16, 2012 7:47 pm

If you really need the sum of the array values, here's an example:

http://dl.dropbox.com/u/33370253/SumArray.capx
B
163
S
120
G
9732
Posts: 42
Reputation: 4,875,331

Post » Fri Nov 16, 2012 7:49 pm

New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
288
S
111
G
94
Posts: 7,332
Reputation: 69,160

Post » Fri Nov 16, 2012 9:03 pm

Thank you, I understand how it works now.
B
74
S
28
G
17
Posts: 256
Reputation: 15,125


Return to How do I....?

Who is online

Users browsing this forum: odiusfly and 23 guests