Hi, I would like to do a graphical countdown that will be visible in the DFrame panel.
I would like it to look more or less like this:
local months = 3
local days = 5
In DFrame there should be a countdown from the current date to the date which will be for 3 months and 5 days.
The problem is that I completely don't understand os.date and os.time, I need help from someone experienced.
Just feed os.date your remaining time (in seconds obviously) and it should care of the rest. As for the format, I believe the example on the wiki provides all the variables you require. Just change up the surrounding text customize it.
os.date("%m months, %d days", timeRemaining)
It seems to me that I have misrepresented what I mean.
I would like to make a countdown, for example from May 1 to June 1, the DFrame panel should show the countdown of how many days have been until the first given date to the second.
DISCLAIMER: I didn't have time to test this so sry if something is not working.
So first of all os.time has an optional table argument DateData. With this argument in play it returns how long is this date in secconds. So to get time difference we just need we just need something like this:
local endDate = {
year = 2019,
month = 6,
day = 1
}
local countdown = os.date(*any template you want*, os.time(endDate) - os.time())
Ok i ran some tests.
https://files.facepunch.com/forum/upload/469093/1b3dd609-f237-44e4-bd38-2cacce96a1ba/hl2_qVvaX809SV.png
One problem i noticed is that end result has hours incremented by 1 and hours incremented by 2 so i just changed them by that.
https://files.facepunch.com/forum/upload/469093/51fe1735-897c-4e1c-9878-5c879fa38b78/Code_fs4ydK3SpI.png
Thank you! You are a really helpful person!
I have one more question - you know maybe it is possible to do something like this:
Choose the starting date, for example 01/05/2019 and the end date, for example 01/06/2019, I would like to do something like loading bar, which would fill with time, on 15.05 the bar should be more or less filled in 50%.
I tried to do it myself, but I need help :/
Something like this.
https://files.facepunch.com/forum/upload/469093/9f1c2d65-8a17-45fa-8b9c-16c08036bb1b/hl2_d3fWuUpsQW.jpg
I pinged you need in case you didn't see the message.
Thanks!
Sorry, you need to Log In to post a reply to this thread.