Problem pulling values from an array

Discussion and feedback on Construct 2

Post » Mon Dec 30, 2013 5:03 am

I am working on a sudoku game and am having trouble getting values out of an array. I load values into an array from a json file, the values show up in debug mode right where they belong. I am using a loop to pull the values out of the array and put them into the squares for the numbers. The first value comes out fine and sets the square to the correct number. From there on out I get only zero. I have shortened the array to simplify testing and the rest of the code and layout is kind of a mess from all my failed testing. But if anyone can help I would be very grateful. I have searched the forums and tutorials and have not found a solution.

Here is a .rar of the whole project so it includes the files I am loading in.
https://dl.dropboxusercontent.com/u/6234471/Sudoku4.rar
B
5
Posts: 3
Reputation: 242

Post » Mon Dec 30, 2013 3:55 pm

I came to the forums just to find out about my array problem. I'm having the same problem. I did find that a one dimensional array can only hold 10 elements. If you read the data at the 11th element I get a bogus result. The manual uses 0-9 (10 elements) as an example, but I guess that also means it's a limitation of the array function.curteck2013-12-30 15:57:30
B
3
Posts: 2
Reputation: 204

Post » Mon Dec 30, 2013 4:58 pm

You are missing a level of square brackets. You only have two dimensions rather than three.

(And you don't need to use RAR, save as CAPX - it does the same thing, and is the standard here for posting files).
{
     "c2array":true,
     "size":[
          1,
          1,
          5
     ],
     "data":
     [
          [
               [
                     "5","2","3","4","5"
               ]       
          ]
     ]
}

@curteck You set the array sizes either in the array's properties tab or via the 'Array:Set size' action.blackhornet2013-12-30 17:01:04
ImageImageImage
B
71
S
21
G
220
Posts: 3,648
Reputation: 123,725

Post » Mon Dec 30, 2013 5:30 pm

THANK YOU blackhornet!!

I didn't think if I just shared the .capx that my data file would be accessible.
B
5
Posts: 3
Reputation: 242


Return to Construct 2 General

Who is online

Users browsing this forum: Glyfos, Mayfly and 6 guests