Oh wait...
You mean that the values of the start button are -1 and 1 ?
I created a extra switch to turn it around. Which makes it go instantly.
Code:
N@CountDown
I@Start Max Min Reset
O@Time
interval(100)
Start==1 & clk() & Time<Max -> Time += 0.1;
Start==-1 & clk() & Time>Min -> Time -= 0.1;
Time<Min->Time=Min;
Time>Max->Time=Max;
Reset->Time=Min;
This code works with a toggle button (-1 Off / 1 On ) connected to start
It should smooth go up and down. It doesn't matter at what moment you toggle Start.
Push button -> it counts to max
Push button again while it's still counting to max -> it counts back to min.
I also added two extra lines to make absolute sure that Time is always between Min And Max
Reset sets the timer back to minimum...Instant.
Code:
N@CountDown
I@Start Max Min
O@Time
interval(100)
Start==1 & clk() & Time<Max -> Time += 0.1;
Start==-1 & clk() & Time>Min -> Time -= 0.1;
Time<Min->Time=Min;
Time>Max->Time=Max;
Same code without reset. Not sure if you need a reset function.
Tested ingame.. works like a charm
Bookmarks