Add 0 to time 00:00?

Have any questions or problems in making your game, subscribing and/or using our software? Post here.
Forum rules
Make sure you are using the newest version. This can be downloaded at the top of the site via the "downloads" link.

Use a very good subject. "Problem" or "Help" are unacceptable titles.

Use the search feature before posting a question, as the answer is probably already here.

Subscript out of range error 9: This is a generic error, and we'll need way more information than that to figure out the problem. If you get this, strongly consider following the instructions of submitting your project through the Submit Bug feature within the editor.
User avatar
Danny
001 Forum Master
 
Joined: Tue Jul 12, 2011 7:14 am

Add 0 to time 00:00?

Postby Danny » Wed Jul 06, 2016 4:37 pm

I can't for the life of me figure this out, some time ago i had this EXACT issue but searching the forums as not shown what am looking for, even tried looking up my old time topics...

When it reaches midnight i want it to display as 00:00 but its displaying as 0:00, also 1:00 should be 01:00, am wanting the 24 hour time thing. Also 1, 2 , 3 , 4, 5, 6, 7 , 8 and 9 seconds should have 0 in front, eg: 01, 02, etc. Anyone know what i need to do? I know it was an easy fix but it was many years ago :(

Thanks in advance.

User avatar
RamchuK_Ntertainment
Ultimate 001 Member
 
Joined: Tue Sep 29, 2009 10:50 pm
Location: Seattle, Washington

Re: Add 0 to time 00:00?

Postby RamchuK_Ntertainment » Wed Jul 06, 2016 4:54 pm

Are you talking about local system time? If so, just use this use-value: Time.Now("%X")

If you're talking about formatting actual elapsed time within the game or variable time, you can use the following format: Text.FormatTimer(Time_Variable,3,0) where Time_Variable would be the time value that you are using.
Travesty: 3D Survival - WIP >>> Forum Topic
University of Washington (BABA)
-REGT- Ramchuk Entertainment Games Team
Strategy/Action/Adventure
Copyrighted©2008-2017

User avatar
Danny
001 Forum Master
 
Joined: Tue Jul 12, 2011 7:14 am

Re: Add 0 to time 00:00?

Postby Danny » Wed Jul 06, 2016 5:03 pm

RamchuK_Ntertainment wrote:Are you talking about local system time? If so, just use this use-value: Time.Now("%X")

If you're talking about formatting actual elapsed time within the game or variable time, you can use the following format: Text.FormatTimer(Time_Variable,3,0) where Time_Variable would be the time value that you are using.


I'm sorry i have never seen this value before? How would i use this? I have two variables "Minutes" and "Seconds" i then retrieve the minutes and seconds through a field using "Combine Text" then i combine minutes and seconds. How would i modify the value you have given so it will fit into a fields retrieve value box?

Thanks.

User avatar
RamchuK_Ntertainment
Ultimate 001 Member
 
Joined: Tue Sep 29, 2009 10:50 pm
Location: Seattle, Washington

Re: Add 0 to time 00:00?

Postby RamchuK_Ntertainment » Wed Jul 06, 2016 5:42 pm

To make things easier, you should consider using a single variable for time; like seconds, unless you really need to track precise milliseconds. In a timer, at a desired interval add 1 to the variable. In context, if you choose to keep track of seconds, know that Integer 1 = 0.001s as a time input; therefore, whenever you retrieve your variable, Integer x 1000 = Actual Time Input. In practice, assume you have variable 'time_' as your tracking variable for seconds; the retrieve code would be Text.FormatTimer(time_ * 1000,3,0). This of course, just tracks time and will go on and on past 24 hours even. Regardless of the format that you are to use, the easiest way to limit the time is to have a Comparison Branch prior to adding time and then checking if the time format is a certain way. For example, if I were to use a 24-hour clock, I might check if Text.FormatTimer(time_ * 1000,3,0) = 23:59:59 or if the variable is equal to the representative time value (86,399)... If so, you can reset the time to accommodate for the restart. You get the idea.

For translation purposes, if you are to use a 24 hour clock, there will be 86,400 seconds in 24 hours. The math is rather simple, so if you ever need a certain time, remember to set it in accordance to what you are tracking; seconds, hours, etc.
Travesty: 3D Survival - WIP >>> Forum Topic
University of Washington (BABA)
-REGT- Ramchuk Entertainment Games Team
Strategy/Action/Adventure
Copyrighted©2008-2017

User avatar
SBG
001 Subscriber
 
Joined: Thu Jun 17, 2010 8:37 pm
Location: merca

Re: Add 0 to time 00:00?

Postby SBG » Wed Jul 06, 2016 6:47 pm

Here's my 12 hour time script. You could probably retrofit it for a 24 clock pretty easily. Just need to take a look at the variables used in it and match them. It's set in a timer going at 1 second. Has some extra stuff with day count and day/night cycle that you'll probably not want to use.

If you want the extra 0s in your display field, set its retrieve text use value to
Spoiler: show
Text.PadLeft(Hour,"0",2)
or something similar. That's what I use for the hour display, obviously.


User avatar
Danny
001 Forum Master
 
Joined: Tue Jul 12, 2011 7:14 am

Re: Add 0 to time 00:00?

Postby Danny » Wed Jul 06, 2016 7:04 pm

RamchuK_Ntertainment wrote:To make things easier, you should consider using a single variable for time; like seconds, unless you really need to track precise milliseconds. In a timer, at a desired interval add 1 to the variable. In context, if you choose to keep track of seconds, know that Integer 1 = 0.001s as a time input; therefore, whenever you retrieve your variable, Integer x 1000 = Actual Time Input. In practice, assume you have variable 'time_' as your tracking variable for seconds; the retrieve code would be Text.FormatTimer(time_ * 1000,3,0). This of course, just tracks time and will go on and on past 24 hours even. Regardless of the format that you are to use, the easiest way to limit the time is to have a Comparison Branch prior to adding time and then checking if the time format is a certain way. For example, if I were to use a 24-hour clock, I might check if Text.FormatTimer(time_ * 1000,3,0) = 23:59:59 or if the variable is equal to the representative time value (86,399)... If so, you can reset the time to accommodate for the restart. You get the idea.

For translation purposes, if you are to use a 24 hour clock, there will be 86,400 seconds in 24 hours. The math is rather simple, so if you ever need a certain time, remember to set it in accordance to what you are tracking; seconds, hours, etc.


Thank you for your help but that actually seems more confusing than how it used to be done way back. I will figure something else out. Thank you for trying to help with this :)

dragonnutds
001 Subscriber
 
Joined: Tue Oct 27, 2009 2:06 pm

Re: Add 0 to time 00:00?

Postby dragonnutds » Wed Jul 06, 2016 7:53 pm

ok, i think i see what you want

there is a use value called format timer, just set the "00 sections" to 1 and you will have time like this
05:32:02


edit: hm, RamchuK_Ntertainment gave that answer allready... i just saw the section about local time, my bad
Last edited by dragonnutds on Wed Jul 06, 2016 7:56 pm, edited 1 time in total.
Reason: Automatically merged double post.
Image

User avatar
Danny
001 Forum Master
 
Joined: Tue Jul 12, 2011 7:14 am

Re: Add 0 to time 00:00?

Postby Danny » Wed Jul 06, 2016 8:10 pm

SBG wrote:Here's my 12 hour time script. You could probably retrofit it for a 24 clock pretty easily. Just need to take a look at the variables used in it and match them. It's set in a timer going at 1 second. Has some extra stuff with day count and day/night cycle that you'll probably not want to use.

If you want the extra 0s in your display field, set its retrieve text use value to
Spoiler: show
Text.PadLeft(Hour,"0",2)
or something similar. That's what I use for the hour display, obviously.



Really sorry i overlooked your post! My bad. Text.PadLeft(Hour,"0",2) was exactlywhat i was looking for! Thank you :D Thanks everyone for your help. :)


Return to Technical Support Questions

Who is online

Users browsing this forum: No registered users

cron