How do I Sum Array please urgent (solve)

Get help using Construct 2

Post » Tue Dec 29, 2015 5:19 am

Last edited by wizdigitech on Tue Dec 29, 2015 3:38 pm, edited 1 time in total.
Image
B
33
S
10
G
2
Posts: 306
Reputation: 3,552

Post » Tue Dec 29, 2015 8:29 am

why not just do on the start of layout after setting the array

0plus2 = Array.At(0) + Array.At(1) + Array.At(2)

If you want to go through the array with for each, you should do it in the start of layout or any other triggered event, so it won't get called endlessly.

I usually do this instead of for each
condition:
repeat Array.Width
then you can can check loopindex value to instead of using another var.

btw, your array was set to 5 width, so the last values did not get registered, you need to expand it to 8.
Image
B
70
S
27
G
12
Posts: 512
Reputation: 12,153

Post » Tue Dec 29, 2015 1:19 pm

This is just a example file
The array size in my game is 600,1,1
Need a easy way to add
From array (0) to array (199)
From array (200) to array (399)
And array (400) to array (600)

Instead of writing out array (0) + array (1) ..............+array (199)
Just need a easier way

edit i forget to mention i already know who to sum up the total value of the array but i cant figure out how to sum up parts of the array

https://drive.google.com/open?id=0BznEF ... GE0SkdTZmM

Image
Image
B
33
S
10
G
2
Posts: 306
Reputation: 3,552

Post » Tue Dec 29, 2015 3:12 pm

You can use a for loop like this:
Image
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,610

Post » Tue Dec 29, 2015 3:21 pm

oh you mean you need a ranged selection, try this
https://drive.google.com/file/d/0B3JLq- ... sp=sharing
Image
B
70
S
27
G
12
Posts: 512
Reputation: 12,153

Post » Tue Dec 29, 2015 3:37 pm

@ramones and @Lof
Thank you Guys that is it
Image
B
33
S
10
G
2
Posts: 306
Reputation: 3,552


Return to How do I....?

Who is online

Users browsing this forum: plinkie and 7 guests