Don't quite understand the Array object...

For questions about using Classic.

Post » Mon Jul 11, 2011 10:02 pm

I figured out that for some reason, you can't set values at 0 indexes. So I began using the X index of 1 to store which save file would be accessed. At this index, 1 = save file 1, 2 = save file 2, etc.

And I thought I could use the Y index as a "subfolder" of sorts, since you can store values at X, Y. I was going to make the first Y index store Health, for example. So 1, 1 would store save file 1's health. 2, 1 would store save file 2's health. 3, 1, you get it...

But apparently, for some reason, I couldn't use the value of 1 for the index of Y. For some reason, it treated y1 as x1. When I tried to store the variable of Health in x1, y1, it ended up being stored in x1 alone. So it had to be put in 1, 2. I couldn't use the index of 1 for the Y coordinate for some reason. Is it supposed to be like that?
B
4
S
2
G
4
Posts: 164
Reputation: 1,878

Post » Mon Jul 11, 2011 10:25 pm

Yes, x1 and y1 are the same. Think of a grid:


    Y
    |
    v
X->   1 2 3
    1 . . .
    2 . . .
    3 . . .


Y coordinates going down, X going across.

That top left "." is 1,1. To use Y as a subfolder for X, you would need to start at 2 for the Y.

Eg.
1,1 = Name (N)
1,2 = Health (H)
1,3 = Speed (S)

This is what it would look like:


- 1 2 3
1 N . .
2 H . .
3 S . .


Hope that helps.


(Edit: formatting)Khalan2011-07-11 22:29:24
B
9
S
2
G
3
Posts: 75
Reputation: 1,964

Post » Mon Jul 11, 2011 10:31 pm

So if you use, "Set value at X", it's being set at xX, y1? y1 will always be used in "Set value at X"? Like just a bunch of boxes? Hm... I imagined it working totally differently. I guess I'll stick with Array for save files then.
B
4
S
2
G
4
Posts: 164
Reputation: 1,878

Post » Mon Jul 11, 2011 10:39 pm

I believe so. "Set value at X" is a 1 dimensional array command - the system will treat it as such and use only the first row.

A one dimensional array would of course simply be:
X: 1 2 3 4 5 ...
with no Y existing.
B
9
S
2
G
3
Posts: 75
Reputation: 1,964


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 0 guests