set multiple values in an array.

Get help using Construct 2

Post » Mon Sep 17, 2012 11:32 pm

I cant get arrays to work. have ready all the man pages, and looked through tutorials. Ive been using arrays for 30 years in probably 20 different languages, including machine code, so am pretty familiar with them.

Im trying to do this as a sub event of on start of layout:

System: For each result -> result : Set value at (result.CurX,result.CurY) to floor(random(9)).

The array "result" is 5x3x1 in size.

The above code only ever sets the first value, so the for loop is getting stuck at 1 iteration.

If I dump the json of the resultant array from the above code, I get:

{"c2array":true,"size":[5,3,1],"data":[[[6],[0],[0],[0],[0],[0]...etc*

*hand typed as haven't found a way to cut and paste the text from a game yet.nutmix2012-09-17 23:51:51
B
15
S
5
G
2
Posts: 357
Reputation: 3,691

Post » Tue Sep 18, 2012 12:16 am

Ok, after many hours of scratching head, Ive figured out the problem. Most of the manuals and tutorials are out of date, and show System loops options which dont exist or have been renamed.

So I assumed that for each = for each element, as I could not find "for each element".

So for each element is an event on the array object, not the system object. Doh! half a day wasted.

Its so easy when you know, and so hard when you dont. nutmix2012-09-18 00:17:07
B
15
S
5
G
2
Posts: 357
Reputation: 3,691


Return to How do I....?

Who is online

Users browsing this forum: mjj1990 and 6 guests