0 Favourites

set multiple values in an array.

  • 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.

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
88 9,238
goldentreee's avatar
goldentreee
Unread hot topic
0 Favourites
Isometric multiple floors
74 9,717
eleanorawesome's avatar
eleanorawesome
Unread hot topic
56 4,727
MPPlantOfficial's avatar
MPPlantOfficial