How do I Check If An Array Cell is Empty?

0 favourites
  • 10 posts
From the Asset Store
Supports 1D, 2D, 3D arrays. Import and export arrays in JSON format
  • Im trying to figure out how to check if an array cell is empty,if anyone knows of this it would be awesome to have help.

  • system compare:,youry) = 0 (or "" if you mean an empty string)

    if you need to go through the whole array and do something with all elements that have a specific value, you can use this:

    array for each element XYZ

    system compare,array.cury,array.curz) = yourvalue : your actions

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • mindfaQ so this would work if I was trying to make my tiles change?

    For example Im trying to make my dirt block turn into a grass covered dirt block but only if the cell above it is free.

    Thats why I wanted to know.

  • Yeah, if you have a 2D-array the tile above would be,array.cury-1), left would be,array.cury) and so on. Be careful on the edges though, as,0) doesn't exist.

  • mindfaQ

    Im not understanding something here bro,This is a way to check just one cell?

    Or can I run this through the whole array?

    It would be awesome to see a visual representation of this but nonetheless I still would love to learn from you.

    I never used before.Im just getting used to arrays in general

  • What I have so far is

    On Start of layout

            For each XY set value at (array.curX,array.curY) to floor (1)

            Create object tiles on layer 0 at (array.curx.array.cury)

            TileArray.CurY > 5

  • I gave you the answer in my first post.

  • mindfaQ

    Thank you so much for showing me what you ment!! You actually shown me a few things I did not know along with my main issue.

    I know you might have told me in an earlier post but I am more of a visual learner. Most teachers have a chalkboard, in our case its a CapX file.thank you once again for your helping hand.

  • mindfaQ

    One thing your capX dosnt show is how to make the upper most cells the same value all while keeping the rest at random.

    I know that round (random (0,4)) will mix things up but how will I dictate that my top cells all stay the same value?

    Could I say an empty cell is 0 and if its true that the cell is 0 I could switch frames accordingly?

  • You can select your first line in the same fashion as you already know ("TileArray.CurY > 5") just use = 0 and curx

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