Page 2 of 4

Re: Creating Independent Counters

Posted: August 13th, 2011, 5:09 pm
by Seahorse
Not the counter, what I'm doing with it - maths... O.O

Re: Creating Independent Counters

Posted: August 13th, 2011, 5:23 pm
by KreAch3R
Seahorse wrote:Not the counter, what I'm doing with it - maths... O.O
Oh, ok. Even more scratching. :p

Re: Creating Independent Counters

Posted: August 13th, 2011, 7:12 pm
by smurfier
Disabling the counter would make it's value 0. To actually stop it while retaining the value:

Code: Select all

[Counter]
Measure=Calc
Formula=Counter+(Counter<#Value#)

Re: Creating Independent Counters

Posted: August 13th, 2011, 8:10 pm
by KreAch3R
Beautiful. :) Wouldn't that work the same as pausing it, however? It provides some additional functionality, nevertheless.

Re: Creating Independent Counters

Posted: August 13th, 2011, 8:18 pm
by smurfier
Yes, that would basically pause the counter at the given value.

Re: Creating Independent Counters

Posted: August 21st, 2011, 3:58 pm
by Seahorse
smurfier wrote:Having it reset after a given value is easy and is accomplished the same way as if you were using the Counter variable.

Code: Select all

[cCounter]
Measure=Calc
Formula=(cCounter+1)%31
This will have the counter reset to zero after it hits 30. Always add 1 to whatever value you want it to reset after otherwise it will reset at that value.
There is a pause after the last number before it starts counting up again, is there a way of removing this? my test skin is counting to 4:

Code: Select all

[CalcCounter]
Measure=Calc
Formula=(CalcCounter+1)%5
but there is clearly a 2 second wait (Update=1000) after 4 before it starts again, i.e. gets to %5, then counts another second before triggering - making a total of 6 seconds total elapsed time for something I am trying to do in 5?

Re: Creating Independent Counters

Posted: August 21st, 2011, 4:07 pm
by smurfier
There should not be a delay like that, or at least none that I have experienced.

Also, if you want it to count 1-4 instead of 0-4 use (cCounter%4)+1

Re: Creating Independent Counters

Posted: August 21st, 2011, 4:42 pm
by Seahorse
Delay is there I can time it. Your suggestion removes the problem:

Code: Select all

[CalcCounter]
Measure=Calc
Formula=(CalcCounter%4)+1

Re: Creating Independent Counters

Posted: September 3rd, 2011, 1:12 am
by KreAch3R
Just a post to cover something that isn't completely covered on the awesome first post:

You can make a counter reset automatically using %value and reset manually using a variable:

Code: Select all

[ScrollCounter]
Measure=Calc
Formula=((ScrollCounter+1)*#restart1#)%61
DynamicVariables=1
IfEqualValue=60
IfEqualAction=!Execute !bangs
IfBelowValue=1
IfBelowAction=!SetVariable restart1 1
In this example, it's a counter that automatically counts till 60, where it restarts and fires !bangs. But I wanted to restart the counter each time I was pressing a button. So the above code will work. I am using it in Kaelri's Evereader, to make the pages scroll automatically, and restart the scroll counter each time I click to see a page (so that I don't see the page for a few seconds before the counter takes it away from me) :)

Re: Creating Independent Counters

Posted: September 3rd, 2011, 2:12 am
by smurfier
To be honest I covered it as well as I felt was necessary. Also, you should be able to cut back on the parenthesis by following the order of operations.

Code: Select all

[ScrollCounter]
Measure=Calc
Formula=(ScrollCounter+1)%61*#restart1#
DynamicVariables=1
IfEqualValue=60
IfEqualAction=!Execute !bangs
IfBelowValue=1
IfBelowAction=!SetVariable restart1 1