I’m currently building a countdown system that works in seconds (see image below), but I’d like to convert it into a clock format — for example, HOUR:MINUTE (HH:MM).
My long-term goal is to create a “Time of Day” system, where each real-time second represents one in-game minute (the exact ratio is still to be decided).
Do you have any idea on how to turn this simple countdown set in seconds into a clock with two separate digits - hours and minutes?
I’ve helped a few get this system together, there are a few things you will want to do:
Thing one is to have a separate values for Minutes and Hours. Time as one float is doable but requires more active math and is less performant. Also, you can make them both Integers, to further simplify, since you are measuring whole numbers.
Thing #2 is you set up your timer by event to add 1 to “Minutes” on a 1s timer. After you add 1 to “Minutes”, check if “Minutes >=60”. If true, set Minutes to 00 and add 1 (or ++) to Hours.
Then thing 3 is if hours was adjusted, you want to check if hours = 13 or 24 (depending on if you want international or AM/PM style). For international use (if Hours = 24, set Hours = 00) and for AM/PM use (if Hours = 13, set Hours = 1).
Lastly, use a Concatenate String node, and convert Hours to string for slot A, add a “:” to slot B, and convert Minutes to string for Slot C. Output that and convert string to Text and there you go!
Hope that helps! If you need more visual aids I can go slap some together.
Hi! Wow, thank you so much for that.
I would love to get some visual references if you don’t mind - especially to see how you set up two co-existing variables (for hours and minutes).
For your last point, I assume you are talking here about the part that goes in the widget to display the hour in the format HOUR:MINUTES?
Yes, it will include a 0 in front IF you assign “Minimum Integral Digits” to 2.
I would use Date/Time if it was going to use more things, I’d do minimum 4, so at least a day of the week calendar on top of time. But for just hour/minute it seems like just too many things going on- to me this is just the same thing with more steps instead of working with simple variables (again, only because it’s 2 numbers instead of year down to ms).
Also, you can customize the method I gave to use your own style of clock, say you want 26 hours in a day, or 10 days in a week, or no weeks, only months. I like it because it can be tweaked. But to each their own!
Hi! I deleted my previous message since I managed to answer my own question.
The clock seems to work perfectly - minus some issues with the formatting. What would be the best way to get rid of the 0s before the hours and minutes?
If you show me your code where you’re doing the “append string”s I bet I could get it figured out really quickly, it’s likely just a logic issue. A < instead of a <= etc.
Yup, that’s what it was! You are using “If Int(hours/minutes) is Less than 10, do not add a 0 before the Int in string”. You need your bool swapped, so you need “Choose A on >=10”.