Sign in to follow this  
taguilo

Timer that counts down, not up.

Recommended Posts

After searching the forum I have found alot of helpfull information on making a timer, I have managed to make a timer that when clicked on starts the timer, when click again stops the timer and when click on again resets the time, but this counts up not down. I am looking to make a timer that counts down from a time set. So when first started sets 30 mins and counts down from 30 mins to 0. I have been playing around with the code and have got it to set 30 mins, but this is only set when the timer is stopped, then when reset it goes back to 00:00. As of yet I am unable to get the timer to count down.This is the code I have for a timer that counts up.%((L:Deptime, Seconds) (L:Off1, enum) (P:Absolute time, seconds) - abs 0 3 (L:OffOnReset,enum) case (>L:Deptime, seconds) (L:Deptime,minutes) 60 % int)%!02d!%:%((L:Deptime,seconds) 60 % int)%!02d!(L:OffOnReset,enum) ++ d 3 != * d (>L:OffOnReset,enum) 1 == if{ (P:Absolute time, seconds) (>L:Off1, enum) } The code I added to get it to set 30 mins, I have tried this along with a lot of other idea's in the click section as well as the value section. (L:Deptime,minutes) if{ (L:Deptime,minutes) 30 (>L:Deptime,minutes)Thanks in advance for any help

Share this post


Link to post
Share on other sites
Help AVSIM continue to serve you!
Please donate today!

Hi,I have somewhere this code, it counts down:%((P:Local Time,seconds) (L:dmetimer,number) - -1 * 0 >)%{if}%((P:Local Time,seconds) (L:dmetimer,number) - -1 *)%!d!%{end}Jan"Beatus ille qui procul negotiis..."

Share this post


Link to post
Share on other sites

Hi I tried your code Jan and could not get it to work, however after trying a lot of different codes I have managed to get a timer that counts down, I do not no why it works, but it does. I had been trying to get P:Local Time,seconds to go backwards and then putting it in to a different variable, but did not have any sucess, so I tried a few different things in the click code and they did not work, so went back to the first click code and forgot to change (P:Absolute time, seconds) to (P:Local Time,seconds) in the click code, tried it one more time before giving up for the night, and when I clicked on it to start the timer, it counts down. I reloaded the aircraft, thinking that it had got confused and would not work after I reloaded it and it worked, shut down my computer and start FS again, still works. Any one no why ?This is a simple timer, shows minutes and seconds, when clicked on for the first time starts the timer counting down, second click stops it and third click reset it back to 00:00. Here is the code:%((L:Deptime, Seconds) (L:Off1, enum) (L:Var1,number) - abs 0 3 (L:OffOnReset,enum) case (>L:Deptime, seconds) (L:Deptime,minutes) 60 % int)%!02d!%:%((L:Deptime,seconds) 60 % int)%!02d!(P:Local Time,seconds) (>L:Var1,number)(L:OffOnReset,enum) ++ d 3 != * d (>L:OffOnReset,enum) 1 == if{ (P:Absolute time, seconds) (>L:Off1, enum) } All I need to do now is get it to set 30 mins when it is first started

Share this post


Link to post
Share on other sites

Hi,Just tested, try:(P:Local Time,seconds) 180 + (>L:timer,number)%((P:Local Time,seconds) (L:dmetimer,number) - -1 *)%!d!% Jan"Beatus ille qui procul negotiis..."

Share this post


Link to post
Share on other sites

>I tried your code Jan and could not get it to work, however>after trying a lot of different codes I have managed to get a>timer that counts down, I do not no why it works, but it does.Russell,It would be easier for you if you try to understand how the code works; would make you save a lot of time doing blind tests :-)I did explained it in detailed pseudocode on the original thread, I hope you've read it.Now, for a countdown timer the solution is simple as well:String part:%((L:DeptimeDown, number) (L:Off1, seconds) (P:Absolute time, seconds) - abs 1 > d if{ (P:Absolute time, seconds) (>L:Off1,seconds) } (L:DeptimeDown, number) r - 1800 3 (L:OffOnReset,enum) case (>L:DeptimeDown, number) (L:DeptimeDown,number) 60 / int)%!02d!%:%((L:DeptimeDown,number) 60% int)%!02d!Mouse part:(L:OffOnReset,enum) ++ d 3 != * d (>L:OffOnReset,enum)1 == if{ 1800 (>L:DeptimeDown,number) (P:Absolute time, seconds) (>L:Off1, seconds) }And this element is not necessary, so you can delete it:(P:Local Time,seconds) (>L:Var1,number)Tom

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this