How do I Check If An Array Cell is Empty?

Get help using Construct 2

Post » Sat Nov 09, 2013 2:13 am

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.
B
9
S
5
Posts: 126
Reputation: 1,295

Post » Sat Nov 09, 2013 2:24 am

system compare: array.at(yourx,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.at(array.curx,array.cury,array.curz) = yourvalue : your actionsmindfaQ2013-11-09 02:26:45
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 788
Reputation: 3,788

Post » Sat Nov 09, 2013 2:30 am

@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.
B
9
S
5
Posts: 126
Reputation: 1,295

Post » Sat Nov 09, 2013 2:36 am

Yeah, if you have a 2D-array the tile above would be array.at(array.curx,array.cury-1), left would be array.at(array.curx-1,array.cury) and so on. Be careful on the edges though, as array.at(-1,0) doesn't exist.
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 788
Reputation: 3,788

Post » Sat Nov 09, 2013 3:00 am

@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 array.at before.Im just getting used to arrays in general TheNewGuy2013-11-09 03:04:43
B
9
S
5
Posts: 126
Reputation: 1,295

Post » Sat Nov 09, 2013 3:13 am

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
B
9
S
5
Posts: 126
Reputation: 1,295

Post » Sat Nov 09, 2013 10:20 am

I gave you the answer in my first post.

http://s000.tinyupload.com/index.php?file_id=02060362440653215196
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 788
Reputation: 3,788

Post » Sat Nov 09, 2013 11:22 am

@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.
B
9
S
5
Posts: 126
Reputation: 1,295

Post » Sat Nov 09, 2013 11:31 am

@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?
B
9
S
5
Posts: 126
Reputation: 1,295

Post » Sat Nov 09, 2013 7:02 pm

You can select your first line in the same fashion as you already know ("TileArray.CurY > 5") just use = 0 and curx
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 788
Reputation: 3,788

Next

Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 39 guests