UI Time & Timer

I’m trying to create a clock (countdown and elapsed time) that the user can see (UI).

What I’m wrestling with is format. I want “mm:ss” (example, 03:23) and the timer node outputs in seconds with base 10 (not 60, but that’s simple division). If this was in a programming language that I was familiar with, I would just use delta time and parse / concatenate / split strings so, that’s the direction that I’m going with nodes but it’s been difficult.

Has anyone solved a node setup for this yet? And should I try to pass properties or strings? Both? What say you, brilliant armorists?

One of the main obstacles I’m facing is how to adjust a variable at the end of a node series or loop. For example, start with 60, subtract 1 and update the variable to 59, then loop. Is there already a post on this that I missed?

Hi,

I made a small online example to show the count down timer in Armory. You can set the number on minutes to count down to and press “Reset” to restart the timer.

I basically use a integer variable as a counter and decrease it every second. I then calculate the seconds and minutes and print it on the screen.

To use variables more conveniently, there is something called Tree Variables. These act as variables in a logic node tree. With this, you can get/set values of this variable.

You can download the example files here. I have tried including some comments in the logic tree. Hope this helps!

3 Likes

Brilliant! Thanks!

I had this going with “On Timer”, “Timer”, a True / False Boolean thing and a secondary count by passing the value through an Object var (Get / Set) and subtracting every second While Timer was running - total pain in the _____ and it made me dizzy to track. It worked, but it looked like spaghetti and was a Rube Goldberg nightmare. lol

Thanks for the example file and pointing to the manual - Tree Variables will be INSANELY helpful in the future!

2 Likes

@QuantumCoderQC - great explanation! I’m adding this post just to tag a few keywords in the thread for future forum searchers.

  • To fellow novices skimming forums, QC’s example file gives a really clean layout of Tree Variables, using floor & modulo to calculate mm:ss and read / display canvas elements to solve a UI Timer that can be set and reset from the UI interface.

  • if you want to link to a game timer (level timing, countdown / count-up, lap time, etc), this graphic (below) along with QC’s example file got me going in the right direction (obviously replace keyboard events with game related triggers, & you’d probably want to set the variable before the timer).

Thanks, again QC! So simple once you see it.

2 Likes