Arrays with more than 3 dimensions

This forum is currently in read-only mode.
From the Asset Store
Supports 1D, 2D, 3D arrays. Import and export arrays in JSON format
  • It would really save me a lot of code for my project if I weren't restricted to arrays with only 3 dimensions. It is possible to get 4+ dimensional arrays in Construct Classic? I've looked around for a plugin or a mod or a workaround of some sort with no success.

    Thanks.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • When data constructions get that complex you shouldn't work with arrays. A better way would be to use custom classes (data structures). lucid's 's' or Python offer that. Ignoring technical aspects it also helps you in the development process to access data with something like

    npc.villager(1).female.lefthand.fruit

    instead of

    array(1, 1, 2, 2, 4)

  • "S" looks like it will work just fine then, thanks a lot.

    I'm strange, and although I would use data structures in CC for some things if I knew how, there's a lot of things I prefer to use numbers for anyway ^_^

  • You could use a 1-dimensional array.

    Say you want a 4-dimensional array 5x6x3x2:

    + System: Start of layout

    -> Array: Set size to 5*6*3*2 x 1 x 1

    + Function: On function "At"

    -> Function: Set return value to 0

    ---+ System: Function.Param(1) is between 0 and 4

    ---+ System: Function.Param(2) is between 0 and 5

    ---+ System: Function.Param(3) is between 0 and 2

    ---+ System: Function.Param(4) is between 0 and 1

    ----> Function: Set return value to Array(Function.Param(1) + Function.Param(2)*5 + Function.Param(3)*5*6 + Function.Param(4)*5*6*3)

    + Function: On function "Set"

    + System: Function.Param(1) is between 0 and 4

    + System: Function.Param(2) is between 0 and 5

    + System: Function.Param(3) is between 0 and 2

    + System: Function.Param(4) is between 0 and 1

    -> Array: Set index (Function.Param(1) + Function.Param(2)*5 + Function.Param(3)*5*6 + Function.Param(4)*5*6*3

    , 0, 0) to Function.Param(5)

    EDIT:

    This is a zero-based array, if you want a 1-based it will require a bit of tweaking.

  • It can get confusing, but you could use a string with nested tokenAt()'s, and different delimiters.

  • ----> Function: Set return value to Function.Param(1) + Function.Param(2)*5 + Function.Param(3)*5*6 + Function.Param(4)*5*6*3

    Shouldn't this line be

    ----> Function: Set return value to Array(Function.Param(1) + Function.Param(2)*5 + Function.Param(3)*5*6 + Function.Param(4)*5*6*3)

    ?

    (I omitted a solution like this because of the complexity. It really isn't very intuitive. But that's totally personal subjective view :D )

  • tulamide

    That's correct, my mistake. I really should have tested it before I posted it to avoid stuff like that.

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