I wanna "Cumulative sum"


Unlike other coding languages, you cannot increment a value as you’re trying to do in totalscore. You get a circular dependency. You may want to look into capture to collect scores for each attempt. Make a numberlist based on its history. And total that score, since it will update each button press.
Keep most of your code, but replace totalscore:

capture(`x`): x
numberList(`L`): this.history(`x`)
totalscore= numericValue(`total(L)`) 

I’m not certain if the numberList will work, so you may need to create it in a graph.

1 Like

Yeah, after looking at it again, in your button CL (without needing separate x variable):

capture(`C`): when this.numericValue=m1.script.C 10 otherwise 0
totalscore= yourGraphsName.number(`T`)

In a (hidden if desired) graph CL:

numberList(`L`):  yourButtonsName.history(`C`)

I usually have a lot of calculations going on which are often easier in a graph:

T= total(L)
1 Like