[Feature Request] Nested Variables/Proper Arrays

0 favourites
  • 4 posts
  • 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.

    *<font size="1">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).</font>

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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

  • Nothing, it's all flat. Currently the only syntax supported is with one dot or for two with behaviors.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)