[CAPX] Summation of instance variables?

Get help using Construct 2

Post » Tue May 09, 2017 8:05 pm

I'm attempting to sum by loops but I'm getting endlessly increasing sum.
Only way I found was to go brute force and sum every instance one by one.

https://www.dropbox.com/s/v9yjbaeb7a7k2 ... .capx?dl=0
Last edited by MPPlantOfficial on Tue May 09, 2017 8:54 pm, edited 1 time in total.
Image Image Image
B
29
S
11
G
27
Posts: 735
Reputation: 17,012

Post » Tue May 09, 2017 8:32 pm

Can't find "Sprite Bank".
ImageImageImage
B
71
S
21
G
232
Posts: 3,696
Reputation: 129,868

Post » Tue May 09, 2017 8:48 pm

blackhornet wrote:Can't find "Sprite Bank".

Oh shoot that wasn't supposed to be there. You know how to do the summation though?
Image Image Image
B
29
S
11
G
27
Posts: 735
Reputation: 17,012

Post » Tue May 09, 2017 8:50 pm

A loop would do it. You have to reset your sum to 0 at the beginning.
ImageImageImage
B
71
S
21
G
232
Posts: 3,696
Reputation: 129,868

Post » Tue May 09, 2017 8:57 pm

blackhornet wrote:A loop would do it. You have to reset your sum to 0 at the beginning.

Fixed link.
I don't understand. Wouldn't resetting sum every loop index give me the value of the last instance only?

(0) Set SUM to 0, Add Sprite(loopindex).VALUE to SUM
(1) Set SUM to 0, Add Sprite(loopindex).VALUE to SUM
(2) Set SUM to 0, Add Sprite(loopindex).VALUE to SUM
.
.
.

Like this?
Image Image Image
B
29
S
11
G
27
Posts: 735
Reputation: 17,012

Post » Tue May 09, 2017 9:07 pm

Sprite:VALUE=1 -> SUM_VAL = Sprite.PickedCount
ImageImageImage
B
71
S
21
G
232
Posts: 3,696
Reputation: 129,868

Post » Tue May 09, 2017 9:32 pm

blackhornet wrote:Sprite:VALUE=1 -> SUM_VAL = Sprite.PickedCount

Sweet. I don't even understand how this works but thank you.
Image Image Image
B
29
S
11
G
27
Posts: 735
Reputation: 17,012

Post » Tue May 09, 2017 9:52 pm

MPPlantOfficial wrote:
blackhornet wrote:Sprite:VALUE=1 -> SUM_VAL = Sprite.PickedCount

Sweet. I don't even understand how this works but thank you.



Here is one example :

Capx: https://www.dropbox.com/s/irznaydpqhbtvx9/Total%20Sum.capx?dl=0
B
38
S
22
G
64
Posts: 242
Reputation: 36,072

Post » Tue May 09, 2017 10:36 pm

blackhornet wrote:Sprite:VALUE=1 -> SUM_VAL = Sprite.PickedCount

Hi.
I tried this modifying the picked count condition to
Value > 0 yet the Picked Count still gives it a value of '1'.

Using the brute force method I could have a values of 100s but the picked count method would still say '6'
Image Image Image
B
29
S
11
G
27
Posts: 735
Reputation: 17,012

Post » Tue May 09, 2017 11:25 pm

You'll have to provide an example again.
ImageImageImage
B
71
S
21
G
232
Posts: 3,696
Reputation: 129,868

Next

Return to How do I....?

Who is online

Users browsing this forum: cb130felix, Kermad, Lancifer, piddlyPoo, yiuyiu6666 and 6 guests