0 Favourites

Array Editor Backwards?

  • Using the new data editor for arrays I always had in my head that X was the row and Y the column. And that's how it shows up in the Debugger.

    But it seems that the X is left to right and the Y is up and down in the new editor. I guess it's not a huge deal, it just seems like it should be the other way around. I can't remember how the C2 data editor worked. Maybe it worked the same way and I just made some hack so that it would make sense in my head.

  • I think it's always been like that.

    X - is usually left to right. (horizontal)

    Y - vertical.

    Z - depth.

    I know sometimes if just feels wrong i don't know why. :p

  • Column major / row major can be pretty confusing, when I was developing the array editor I actually had it the wrong way round for several months. During the alpha Kyatric noticed it was flipping the data around each time you saved and re-opened a file. It should match how the runtime actually reads the files currently.

    I guess if it gives you real headaches then you could create a feature request for a "invert array editor" setting? Can see how much traction it gets

  • Well it is actually based on maths (in an orthonormal plan X is horizontal and Y vertical).

    It is actually how coordinates work in the layout view as well (where the origin point is actually top left and the Y axis actually goes "down").

    The C2 data editor is a third-part application, there is no actual editor for C2, but according to the video example in the store, columns are used in a spreadsheet way. I haven't been able to see so far how it actually translates once in JSON imported in Construct. But you would have each X representing an actual column, and then each Y being an "index".

    I would argue though that "spreadsheet" way makes more sense for humans to read.

    The issue then being, you would have to "twist" the position in your mind/events when you are actually reaching for the coordinates in code.

    For example, and still according to the example video, at 2:15 for example as it is being displayed:

    X (horizontal)

    0 = ID, 1 = Name, 2 = Value, 3 = Modifier

    Then the Y (vertical, each rows)

    Y 0 = skipped, used to name the columns

    Array.At(1,2) = Wand +2 (Name of ID 1)

    Array.At(3,5) = 4 (Modifier of ID 4)

    In a logical way, you would tend to use X as ID, and for each ID have then 3 Y (Name, Value, Modifier) you can relate to.

    X> ---------------- 0 ---------------- 1 ---------------- 2 ---------------- 3 ---------------- 4...

    Yv

    Name ------ Wand +1 ------ Wand +2 ------ Wand + 3 --- Wand +4 --- Wand + 5 ...

    Value ----------- 1 ---------------- 2 ---------------- 3 ---------------- 4 ---------------- 5...

    Modifier ------- 1 ---------------- 2 ---------------- 3 ---------------- 4 ---------------- 5...

    In this setting :

    Array.At(1,0) = Wand + 2 (Name of ID 1)

    Array.At(3,2) = 4 (Modifier of ID 3) (which is the fourth entry because arrays are 0 based)

    Less "readable", but true to logic.

  • I've spent the past 2 weeks making my own Array Editor. Maybe worth releasing/sharing?

  • I would definitely be interested.

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • The way we were taught in school was X is like a cross symbol (across), and Y is like an arrow symbol pointing down (up and down).

  • Certainly I'd always choose x horizontal and y as vertical when making a table. It's the standard for 2D space after all, so long as your not talking about kinematics which uses i and j instead.

    I was more commenting on the fact that internally in construct the JSON data is stored as columns which is nice and logical for reading a cell.

    [quote:1ki6m6w6]

    | | | | | | X

    | | | | | |

    | | | | | |

    | | | | | |

    Y

    var cell = obj[x][y];[/code:1ki6m6w6]
    
    However, typically table data is stored as rows, as it makes it easier to insert new rows. When you're using rows getting the entry for a cell in that format is the opposite way around.
    [quote:1ki6m6w6]
    ___________
    ___________ X
    ___________
    ___________
    ___________
    Y
    
    
    
    [code:1ki6m6w6]var cell = obj[y][x];[/code:1ki6m6w6]
  • I made an array tool for my project. Here is a version that draws a 2d table left to right row by row

    Note that X and Y are incorrect:

    https://people.uta.fi/~a628495/_other/c2_arraymaker/

    This version fixes the problem. It draws the table top to bottom column by column

    You can see when you click on an input field it shows the array indexes in the top bar.

    https://people.uta.fi/~a628495/_other/c2_arraymaker_v2/

    Edit: edited for the new forums

  • Your editor is really well done IMHO, simple & effective with a neat UI.

    I'm using it just now for my last project, thanks!

  • Your editor is really well done IMHO, simple & effective with a neat UI.

    I'm using it just now for my last project, thanks!

    Thank you! I may add support for 3 dimensional arrays later.

    Here is a zip package if you want to download the array maker. It doesn't need a web server to run.

    https://people.uta.fi/~a628495/_other/c2_arraymaker_v2/arraymaker.zip[/code:1kd06mtn]
  • Great! downloading, thanks again

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