Wanted to make a timer/counter. Did so. :3
This uses func\_brush for the numbers (7 for each number), a logic_case and a math\_counter for each number.
It's pretty much just a counter, but adding a logic\_timer with a refire of 1s means it can be used as a timer too. The timer adds 1 to the counter every second, which sends its current value to the logic_case. The logic\_case compares the number input from the math\_counter to the cases it has, and fires the first case that matches. Depending on which case is fired, it enables or disables each func\_brush to show the number.
When the counter hits its max (which is after 10s) it adds 1 to the other counter, which controls the 2nd digit (the tens). The 2nd digit's counter does the same as the first, but it's triggered every ten seconds by the first counter instead of the timer.
You could add more digits by copying and renaming the 2nd (left) digit with its case and counter. Then add an output on the 2nd digit's counter to add 1 to the 3rd digit's counter OnHitMax (pretty much copy the 1st digit's output to the 2nd).
At the moment, it goes up to 99 and then resets and disables itself. To stop this, remove the current OnHitMax output on the 2nd digit (OnHitMax, resetBtn, press). If you want to use it as a timer, I'd suggest setting the "Maximum Legal Value" of the 2nd counter to 6.
If used please credit me in some way.
Updated! Now clamps at 00.
Edited the timer to count down instead of up, if you want that. Currently counts down from 60. I've edited it to be easier to read. You no longer need to add 1 to the first digit, just set it to what you want. It's pretty self explanatory.
For those who don't understand:
Change the initial values to the numbers you want. For example, if you want it to start at 45 seconds then set the initial value of the "digit1\_counter" counter to 5 and the initial value of the "digit2\_counter" counter to 4. As you can see, digit2\_counter controls the left or tens digit, while digit1\_counter controls the right or singles(?) digit.
I think that's all that needs explaining. If you need some help just ask.
Full Countdown Timer with Minutes
(Shown in the last two screenshots.)
After a few requests I have finally updated the timer to have two minute numbers, so it can now go from 99:59 (you could make it 99:99 but as it acts as a real timer there are 60 seconds) to 00:00. At 00:00 the timer will stop.
Adding a Function/Ending When it Hits 00:00
To make it do something when it hits 00:00, simply add the output to the digit\_relay\_end logic\_relay entity. This is also the entity that stops the timer. So, for example, if you want to end the game when it hits 00:00, make a game_end entity, name it something (eg "ender"), then on the digit\_relay\_end entity add the output OnTrigger, ender, EndGame.
Round Resets: Just a note that func\_brush entities do NOT reset on new rounds. You will need to reset them manually using a logic\_auto entity. You can do this easily by setting the oounter values again, as this will trigger the logic\_compare entities to enable/disable the func\_brush entities.
If you don't understand:
Add a logic\_auto entity to the map (if you already have one then add the outputs below to the existing one).
Add the following outputs to it
Remember to change 0 and 6 to your initial values. These go in the parameter override field not the delay field.
If you are using the reset button then simply have the logic\_auto press the reset button (OnMapSpawn, reset\_btn, Press).
If you don't reset them then they will simply go back to normal after the counters change.