How do I get all values from Array on Dimension Z to show on

Just started using Construct 2? Post your questions here

Post » Thu Jan 14, 2016 11:40 am

Hello ,

I have an array which has x,y,z dimension.

On Z dimension , i have five values , "orange" , "apple" , "strawberry" , "carrot" , "banana".

I need to get all values and print them on text box.

I am doing like this ;

Image

Now , i have several problems ,

I can't pull all array values to textbox2 to show it who type "banana"

I tried to use Array.CurZ expression or Array.Depth it didn't work.I checked getting random values from array , i understand the perfectly yet i can't managed to list all values to show in textbox2.

Could you please show how i can make this right or should i make it same Array.at expressions for all choices to list on textbox2 ?

Edit;Checked several times here scirra/manual/108/array ; couldnt figure it out which expression should i used it ...

edit 2 ;

I can do it like array.at(0,0,1)&","&array.at(0,0,2) and it works good but if i have hundreds values in array , it is not the good way to print it.

So is there any trick on expressions that i do not know about to print all of them ?
B
4
Posts: 7
Reputation: 214

Post » Thu Jan 14, 2016 2:22 pm

For "z" 0 to Array.Depth-1 -> Array.At(loopindex("z"))

That will loop through each item in Z.
ImageImageImage
B
71
S
22
G
241
Posts: 3,734
Reputation: 134,494

Post » Thu Jan 14, 2016 3:04 pm

Hello ,

Thank you for your answer ,

I tried and it was like this

Image


but i got this result;

Image


Thank you again for helping , sir/ma'dam.
B
4
Posts: 7
Reputation: 214

Post » Thu Jan 14, 2016 3:07 pm

Swap the For & the TextBox events.
ImageImageImage
B
71
S
22
G
241
Posts: 3,734
Reputation: 134,494

Post » Thu Jan 14, 2016 3:13 pm

I tried , i got same result. It shows only "banana,"


edit; i guess it loops and stop on "banana" instead of printing all of them in 1 line.
B
4
Posts: 7
Reputation: 214

Post » Thu Jan 14, 2016 3:32 pm

ImageImageImage
B
71
S
22
G
241
Posts: 3,734
Reputation: 134,494

Post » Thu Jan 14, 2016 3:46 pm

Thank you so much for example and sharing it for me and thank you for spending time to helping to me.

If you dont mind , Can i ask , why do we required to use Variable1 ? was that an important function for this problem ?
B
4
Posts: 7
Reputation: 214

Post » Thu Jan 14, 2016 3:59 pm

You have to build up the list of elements. The Text object has an Append action, but TextBox doesn't, so you need to append the list manually. Otherwise you would be replacing each element with the next one. I think your main problem was not setting the size of the Z dimension, so your depth was actually only 1, therefore stopped at "banana".
ImageImageImage
B
71
S
22
G
241
Posts: 3,734
Reputation: 134,494

Post » Thu Jan 14, 2016 4:14 pm

I see , thank you for information and kindness.

I checked array z dimension depth it was 7 so i still don't know what went wrong if that was good algorithm. :)
B
4
Posts: 7
Reputation: 214


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 3 guests