Array woes

0 favourites
  • 8 posts
From the Asset Store
Supports 1D, 2D, 3D arrays. Import and export arrays in JSON format
  • I'm having some really annoying issues with arrays. Maybe I'm just not understanding how they work on a fundamental level.

    I have an array like this one with some values filled in that pertain to characteristics of the the characters at the top. Things like age, gender, eye color etc. I set all this up at the start of the layout.

    I want to be able to add NEW characters into the array but every time I try to do that the array gets really weird in the debug layout. For example if I try to insert another character named "Jim" on the x axis he'll be inserted at the front of the array no problem...but if I try to add the other values, gender and so on they'll be strewn throughout every corner of the array.

    Everythings good.

    And then I insert new values...

    What the heck?

    Also, by default an array has a 1 for depth, if I turn that to zero (because why the hell would I need zdepth in a 2d array, right?) this happens.

    Can anyone clue me in on what exactly it is that I'm doing wrong here? What am I not understanding?

    Thanks for any help.

  • If you insert at 0, then that column is already there. Don't insert any more, just set the rest of the data at index 0.

    C2 has it's own rules for arrays. Even if not used, the default size needs to be 1.

  • blackhornet

    Ohh, I think I see. So I'm inserting twice and that's basically shifting all of my values over twice? I still don't understand how the other characters are ending up with 3 values for gender though. Shouldn't that stay at 2 regardless?

    That's a problem. Inserting values seemed ideal since I don't want to have to set values at specific indexes later in game. I want to be able to just "insert" a new row and column sort of dynamically and be done with it.

  • Think of it as inserting a column, then inserting a row - the array grows in both dimensions then.

  • blackhornet

    Okay, okay yeah that makes a lot of sense actually.

    Thank you very much

  • If anyone can give me a tip though on how to add multiple values into an array without having to put them at specific indexes though it would be appreciated.

    Like it would be nice to add someone's name and have all the associated data go along with it in that same column. Is that something that's even possible?

  • insert your info as a string............arr_npc>insert "jim"&","&"male" at index 0 on x axis and then retrieve it with tokenat

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • granpa okay, I'll give that a shot. Thank you very much

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