How do I insert and read numbers from an array? [SOLVED]

Get help using Construct 2

Post » Sat Feb 11, 2017 3:59 pm

Image

Here is a picture of what I would like to do. The 1's are being used to test. In the final version, I would like to use the game settings to save high scores in a 3 x 3 x 2 array.

In this test, the SpriteFont shows the number at position 1,1,1. When the score is greater than the highscore at that position, it sets that position to the score. However, in game, the SpriteFont never changes and displays a zero no matter how high the score goes. What am I doing wrong?

Clarification edit: The "Every tick" is not a sub event of anything else. Any advice would be appreciated!
Last edited by PixelLab on Sat Feb 11, 2017 5:32 pm, edited 2 times in total.
B
7
Posts: 24
Reputation: 320

Post » Sat Feb 11, 2017 4:35 pm

Indexing starts at 0, not 1, so you should be starting at 0,0,0.
ImageImageImage
B
71
S
21
G
220
Posts: 3,648
Reputation: 123,725

Post » Sat Feb 11, 2017 4:42 pm

Ok, but isn't there also a value at the position 1,1,1 in a 3x3x2 array? Regardless of where I start, why isn't it able to set and display a value at a specified position?
B
7
Posts: 24
Reputation: 320

Post » Sat Feb 11, 2017 4:44 pm

It wasn't clear what sizes you are using. You said the final version would be 3,2,2, but if you didn't change that now, the default would be 10,1,1, which would fail to work at index 1,1,1.
ImageImageImage
B
71
S
21
G
220
Posts: 3,648
Reputation: 123,725

Post » Sat Feb 11, 2017 4:47 pm

It's out of the bounds of the array so always returning 0, you need to set the size of the array.
B
45
S
15
G
73
Posts: 2,006
Reputation: 43,394

Post » Sat Feb 11, 2017 4:49 pm

Ah, fair point, I should have been more clear. The current array (the one used when this example was run) has a width of 3, height of 3, and depth of 2.

Any idea why the example in the picture isn't working?
B
7
Posts: 24
Reputation: 320

Post » Sat Feb 11, 2017 5:02 pm

ImageImageImage
B
71
S
21
G
220
Posts: 3,648
Reputation: 123,725

Post » Sat Feb 11, 2017 5:32 pm

Solved, thanks to blackhornet!

My solution was to delete my array and redo it. I'm not sure why that fixed it, but it worked!
B
7
Posts: 24
Reputation: 320


Return to How do I....?

Who is online

Users browsing this forum: varr and 3 guests