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
8
Posts: 24
Reputation: 345

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
22
G
241
Posts: 3,734
Reputation: 134,494

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
8
Posts: 24
Reputation: 345

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
22
G
241
Posts: 3,734
Reputation: 134,494

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
46
S
16
G
79
Posts: 2,170
Reputation: 46,857

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
8
Posts: 24
Reputation: 345

Post » Sat Feb 11, 2017 5:02 pm

ImageImageImage
B
71
S
22
G
241
Posts: 3,734
Reputation: 134,494

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
8
Posts: 24
Reputation: 345


Return to How do I....?

Who is online

Users browsing this forum: Kin, mickclarke, tinhofiel, TRMG and 48 guests