[ARRAY] Action -> Save value

Get help using Construct 2

Post » Thu Sep 10, 2015 5:05 am

I read the FAQs, I understand partially the arrays, i read the tutorials, but i cant find in the forum a capx example or question of how to save value in an array in a current action over object, please check my events or capx and please teach me how to do this correctly, i want to spawn 2 objects (of value 0 in the array), show some values in text object, save array info, after 2 objects are destroyed then spawn another 2 objects, please check comments in capx .....

Image

Image

capx
http://www.filedropper.com/arrayspawnandsetvalues
B
9
S
3
Posts: 142
Reputation: 1,108

Post » Thu Sep 10, 2015 6:14 pm

why arrays are so hard :\
B
9
S
3
Posts: 142
Reputation: 1,108

Post » Thu Sep 10, 2015 8:47 pm

Your array seems fine. It's your other events that are mixed up. See if this helps. You were loading your array after creating your cubes, due to the Destroy. I've moved the cube off of the layout, and call Spawn directly on startup.

www.blackhornettechnologies.com/Constru ... s_BHT.capx
ImageImageImage
B
71
S
22
G
249
Posts: 3,763
Reputation: 138,577

Post » Thu Sep 10, 2015 10:41 pm

blackhornet wrote:Your array seems fine. It's your other events that are mixed up. See if this helps. You were loading your array after creating your cubes, due to the Destroy. I've moved the cube off of the layout, and call Spawn directly on startup.

http://www.blackhornettechnologies.com/ ... s_BHT.capx


i am using the debugger to check the array values and the value of color didn't change in the array and the value of the level didn't change correcly in the array when the object its overlapping.

I am trying to use my logic here and i don't understand why didn't work.

Image

Image
B
9
S
3
Posts: 142
Reputation: 1,108

Post » Thu Sep 10, 2015 11:17 pm

I suggest you drop the Array FOR events, and stick to the system FOR loop. You are mixing one and two dimension events, which is confusing things.

http://www.blackhornettechnologies.com/ ... BHT_b.capx

Event 8/9 doesn't work because you change the colour to black and then try to find the matching colour, which you just set to black, so it doesn't exist. For 11/12, you are trying to set to CurY but there is no CurY as you are only looping in X.
ImageImageImage
B
71
S
22
G
249
Posts: 3,763
Reputation: 138,577

Post » Thu Sep 10, 2015 11:23 pm

blackhornet wrote:I suggest you drop the Array FOR events, and stick to the system FOR loop. You are mixing one and two dimension events, which is confusing things.

http://www.blackhornettechnologies.com/ ... BHT_b.capx

Event 8/9 doesn't work because you change the colour to black and then try to find the matching colour, which you just set to black, so it doesn't exist. For 11/12, you are trying to set to CurY but there is no CurY as you are only looping in X.


Now its replacing for example the orange value in the entire array not only in the specific object, for example i clicked orange object but didn't click Carrot Object but in the array now the value of carrot color its black, isn't possible to modify the array just picking the object? overlapping -> set value in the object didn't work too.

Image

If i am overlapping an object or clicking an object i just want that construct2 find in the array the object by name (names are in Y1, for example c2 will find carrot in Y1) and modify a value of the object, for example i clicked a carrot then construct2 will find the carrot object in the array and then will modify the value of the color "orange" to "black", and if for example i am overlapping the object then sum +1 to the level of the object, i am trying to do this in the capx.
Last edited by Majinboo on Thu Sep 10, 2015 11:41 pm, edited 1 time in total.
B
9
S
3
Posts: 142
Reputation: 1,108

Post » Thu Sep 10, 2015 11:38 pm

Just store the loopindex in the redcube when you create it, then you now exactly which X to index.
ImageImageImage
B
71
S
22
G
249
Posts: 3,763
Reputation: 138,577

Post » Fri Sep 11, 2015 12:08 am

blackhornet wrote:Just store the loopindex in the redcube when you create it, then you now exactly which X to index.


Now its working ok to replace the color value, however i tried to replicate this with the overlapping object to modify level value but didn't work, the browser events are only useful with mouse clicks?

Image
B
9
S
3
Posts: 142
Reputation: 1,108

Post » Fri Sep 11, 2015 12:21 am

You don't need the For loops now, you have the index already! Post the code again.
ImageImageImage
B
71
S
22
G
249
Posts: 3,763
Reputation: 138,577

Post » Fri Sep 11, 2015 12:36 am

i tried removing for loops but didn't work :(

http://www.filedropper.com/arrayspawnandsetvaluesbhtc
B
9
S
3
Posts: 142
Reputation: 1,108

Next

Return to How do I....?

Who is online

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