Reset point to origin on button click

Hello Desmos Forum,

I have a graph with a point at (n,0) where n has a slider that allows the point to be moved by students from -7.5 to 7.5, based on a button submission. On the button component, I used the resetOnChange sink in hopes of finding a way to use it to reset the student moved point back to the origin for the next round. How do I use the click from the resetOnChange to reset “n” back to zero for the next button submission?

Thanks,
Richard

Before this one gets buried: Button Reset • Activity Builder by Desmos

resetOnChange won’t help you, but you can use capture to place it back where it started. This is also not the only way to do this, so welcoming others to join in with their solutions!

I figured it out based on one of your previous posts that I found after a lot of searching. It was another button reset post you did with f(x)=1/x.

The button CL is:

capture(“ncap”): coloramagraph.number(“n_1”)
resetLabel: “Move the point back to orange and click this to reset.”
disabled: this.pressCount = 20

The graph CL is:

r = randomGenerator(flipper.pressCount)
number(“C”): r.int(1,8)
number(“n_{cap}”): firstDefinedValue(flipper.lastValue(“ncap”),0)

My function is f(x)=0 and I used your point at:
(n_{startx}+n_{1}-n_{cap},f(n_{startx}+n_{1}-n_{cap}).

Now for my admission. I can robotically copy what you are doing, but I don’t totally understand why this resets the point back to the beginning. Any insight will help me grow with CL coding.

Thanks Again
Richard Punches

In a nutshell, because we can’t actually reset the slider back to zero, we capture the distance it has traveled and subtract it from the slider. Then we base the location of the point on that difference rather than the slider itself.