Array size (1,1,1) = (2,1,1)?

Discussion and feedback on Construct 2

Post » Sat Feb 09, 2013 7:56 am

So I was having trouble accessing the elements of my arrays correctly, and I think I found the problem.

Say I have an array and set its size to (1,1,1), then push a 9 to the back.
When I tell my string object to display Array.At(0) (which should be the first and only element in an array of this size), it says "0." However, when I set it to Array.At(1), it shows "9"

When I set the array size to (0,1,1) which, according to the manual, should be illegal, the textbox shows "9" at Array.At(0), and "0" at Array.At(1), meaning that the array has a width of 1.

So it seems like arrays always set their x-width to one higher than you specify. Am I right, or just missing something?
Posts: 2
Reputation: 754

Post » Sat Feb 09, 2013 8:23 am

Setting the size to 0 allows for the push action, creating an index for the newly pushed value.

If you push a value in an array of width=1, is already = 0 and your new value will be put in index 1.
If you push a value in an array of width=0, your new value will be put in index 0.

Pop actions works the same, deleting/removing the specified index (back or front).

Perhaps the manual needs an update on that specificity, pop and push actions were added after the first edit of the entry.
@Ashley, you probably have a better way to formulate the explanation and perhaps could edit the entry ?Kyatric2013-02-09 08:25:55
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Posts: 7,357
Reputation: 72,828

Post » Sat Feb 09, 2013 9:26 am

Oh okay, I thought that "size" was the max number of values the array was allowed to hold, rather than just the starting size. Thanks for clarifying.
Posts: 2
Reputation: 754

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 8 guests