Array Condition example cap....

Post your own tutorials, guides and demos.

Post » Mon Mar 02, 2009 12:16 am

...as per the discussion in the help forum.
B
2
S
1
G
3
Posts: 105
Reputation: 1,310

Post » Mon Mar 02, 2009 8:52 am

Contra! ;)

I've attached an example that uses the 'for each element' Array condition. In order to output a certain index only (the first Z layer), add a condition that compares the Array.CurrentZ to the index you want. Remove that condition and it'll display the whole table.

It seems that Array object is still 0-indexed... Is this intended? I was under the impression that this was changed to 1-indexed.
[quote=Construct 0.98.8]- [CHANGE] Array is now 1 based; if you use Array in a project please review and update your events accordingly[/quote]
This obviously isn't true in our case.

Also, your example should work, but it apparently doesn't, which should be considered a bug. The 'for (n)" aren't at fault here, it is the Array condition that is not doing its job. The Array - Compare value at X,Y,Z appears bugged, you could use the X,Y or X variants instead. I will report this to the tracker.

So, in your case, it would be:
[code:2tpotvn2]
+Trigger Once
+For "x" from 0 to 99
+For "y" from 0 to 99
+Array - Value at LoopIndex("x"),LoopIndex("y") equal to 0
> List: Add "Yes"
[/code:2tpotvn2]
But that is redundant, since "for each element" array condition does the job just fine as shown in my example. ;)


Also, use "Trigger Once" system condition so the event should evaluate once only; by itself it will keep triggering each tick.
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Mon Mar 02, 2009 4:39 pm

Parts of the Array object were 1-based and other parts were 0-based, like the Array(x, y, z) retrieving syntax. I've fixed it for the next build - it should all be 1-based then.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,610

Post » Tue Mar 03, 2009 1:08 am

[quote="Ashley":236kjfp8]Parts of the Array object were 1-based and other parts were 0-based[/quote:236kjfp8]
That's what I surmised in my post in the main 0-index vs 1-index thread.
Don't know if you saw that, but glad to hear that it's fixed for the next build.

Those bugs are falling one by one eh? :)

Incidentally, another recently discovered bug is that the date object returns the year as 109 instead of 09 when you choose a format that has only 2 digits for the year.
Don't know if it's been tracked yet.

Sponge.
B
2
S
1
G
3
Posts: 105
Reputation: 1,310

Post » Mon Nov 16, 2009 10:18 am

Sorry to bring this old thread up, but Mipey's example answered a question on arrays for me.
That being if the for each condition cycled each z. Apparently it does. :D
It's also a good example of the order for which each is called.
Thanks
Image Image
B
161
S
48
G
91
Posts: 7,358
Reputation: 67,271


Return to Your tutorials & example files

Who is online

Users browsing this forum: No registered users and 1 guest