[Feature Request] Nested Variables/Proper Arrays

Discussion and feedback on Construct 2

Post » Fri Dec 21, 2012 4:15 am

I'm a bit bothered with the fact that we're limited in our variables, whereas pure javascript is so powerful.

I'm having to make lots of custom plugins to counteract this simple problem: You cannot nest variables, arrays are not associative (which is fine) and limited to three dimensions.

Since you are limited to one level, you cannot add variables to variables. So something like player.options.name is impossible to achieve. This goes back to my feature request requesting a way to categorize variables. I'm not asking for variables to actually BE inside one another, as in javascript - this can (and probably should) be a purely IDE thing. We need to be able to assign variables to groups, and assign those groups to subgroups - that is all.


Now onto arrays. If you are making a 2D tiled map, for instance, you can use an 3-dimension array to store information about your tiles: X and Y are normal coordinates, and you use the numbers in Z to store your information, so 0 might be "tile ID", 1 might be "tileset ID", 2 might be "is this an obstacle?", 3 might be "is this animated?" and so on.

When you make a 3D tiled map however, stacking tiles on top of each other (making blocks - as in dwarf fortress or tibia), you need the third dimension to represent an actual coordinate, losing the ability to store values. You then need to create another array, and store a pointer to a position in this other array.

It would be nice if we could add variables of type array into objects instead, and use bracket notation to work with them - thus freeing us to work in more than 3 dimensions.

*For those that don't get this technique, you simple create two arrays - Let's name them "coordinates" and "values".

You use X, Y and Z to refer to coordinates, and since you can only store ONE value, you store a sequential number. Your "values" array is two dimensional. Your X dimension is sequential, and your Y dimension is your values, so 0 might be "tile ID", 1 might be "is this an obstacle?" and so on.

If you want to know the properties of a tile, you check the "values" array at position x=(whatever is stored in the "coordinates" array for that XYZ coordinate) and y=(number of the property you want to know about).
Fimbul2012-12-21 04:17:20
B
35
S
8
G
8
Posts: 532
Reputation: 6,868

Post » Fri Dec 21, 2012 1:41 pm

I've thought a lot about this but it would require a significant overhaul of the expressions system to be able to support it. It's a large amount of work and likely to be very difficult to get right, so I don't think it's something we'd take up immediately. But perhaps in the long term.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,580

Post » Fri Dec 21, 2012 5:46 pm

@Ashley, what about the variable grouping being used only in the IDE? This way nothing would have to change on the underlying engine, and we'd still be able to organize our variables
B
35
S
8
G
8
Posts: 532
Reputation: 6,868

Post » Fri Dec 21, 2012 8:01 pm

Nothing, it's all flat. Currently the only syntax supported is with one dot or for two with behaviors.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,580


Return to Construct 2 General

Who is online

Users browsing this forum: zenox98 and 8 guests