Set Array value not working...

Get help using Construct 2

Post » Sat Nov 10, 2012 9:52 pm

I've got a simple array setup and have set a couple of values:



But for some reason the debugText always displays "Can you get that chest? -- 0"

So the value at 2,1 never seems to get set. Am I doing something wrong (likely) or is this a bug?

Cheers!
B
5
Posts: 11
Reputation: 722

Post » Sun Nov 11, 2012 12:43 am

maybe try to make debugText bigger/wider/taller so it will fit the long text.
B
34
S
13
G
8
Posts: 134
Reputation: 8,118

Post » Sun Nov 11, 2012 1:27 am

This plugin is great for debugging arrays: http://www.scirra.com/forum/log-text-Objects-to-chrome-console_topic47859.html

But yeah, it sounds like the text object isn't big enough.thehen2012-11-11 01:28:50
Moderator
B
72
S
13
G
11
Posts: 900
Reputation: 11,783

Post » Sun Nov 11, 2012 2:25 am

I think the cause is that your array isn't sized correctly to hold the values. Quoting from the manual entry on arrays: "Arrays do not automatically resize. If you access a value outside the array bounds, it returns the number 0. If you set a value outside the array bounds, it will have no effect."
You can see that you are getting the value "0" returned instead of your array contents as described.

Have you adjusted the size of your array ("width" and "height" under properties) so that they are the correct size? Even though you're not using it in your example you also need to set the depth to a size of 1 or higher, as if any dimension of the array is size 0 the entire array is considered empty.


Does that help?
B
24
S
5
G
2
Posts: 104
Reputation: 3,136

Post » Sun Nov 11, 2012 10:39 am

Thanks for the help guys, turns out it was the size of the array that was wrong! Cheers for that :)
B
5
Posts: 11
Reputation: 722


Return to How do I....?

Who is online

Users browsing this forum: Google [Bot], Yahoo [Bot] and 20 guests