Millisecond Forums

## Getting the counter to reset when it hits 0

https://forums.millisecond.com/Topic15738.aspx

 By aghartley - 3/10/2015 Hello,I am designing an experiment in which participants can either earn money (incentive) or lose money (decentive) for correct guess per trial. For example, if it's an incentive block, participants will earn \$.15 for each correct guess per trial within that block. But if the next block is a decentive block, they will lose \$.05 for each correct guess.I'm using the counter element so that participants can keep track of their earnings. However, currently, as I've programmed the experiment, if participants lose money below \$0, the program records negative numbers, but their counter amount shows \$0. So, when participants start earning money again, they need to get out of the negative range before the counter will show anything over \$0.Basically, I need to know how to get the counter to reset the participant's earnings to 0 when they dip into the negative digits (we are not interested in having participants owe money for this task). Would I do this using the reset interval attribute? Or would I need to fix something elsewhere in the code, outside the counter element?Please let me know if you'd like to see my code. Thank you! By Dave - 3/10/2015 I'm not sure why you would use a to keep track of earnings at all. The best-suited element for that is a entry -- you simply update that value by adding or subtracting earnings or losses. Setting that value to zero if it goes negative is trivial./ points = 0/ trials = [1-10 = mytrial]/ ontrialend = [if (trial.mytrial.response == 17) values.points += 10]/ ontrialend = [if (trial.mytrial.response == 38) values.points -= 10]/ ontrialend = [values.points=max(0,values.points)]/ stimulusframes = [1=mytext, mypoints]/ validresponse = ("w", "l")/ items = ("Press 'W' to win points, press 'L' to lose points.")/ items = ("Your have <%values.points%> points")/ position = (50%, 10%)/ erase = false/ size = (25%, 10%)A 's /resetinterval will not help you, nor will explicitly calling the reset() function on it. Neither changes the counter's *contents*, both merely reset it's selection pool.