scratcher911 Posted September 9, 2012 Posted September 9, 2012 Hi. I am using getRealTime function. So if the time is 4 o'clock it shows 4. I wanna that it outputs 04 instead of 4. How? Greets: ScratcheR
Scripting Moderators Sarrum Posted September 9, 2012 Scripting Moderators Posted September 9, 2012 function getGameTime ( ) local time = getRealTime ( ) local hours = time.hour local minutes = time.minute if hours < 10 then hours = "0" .. hours end return hours .. ":" .. minutes end -- outputChatBox ( getGameTime ( ) )
Scripting Moderators Sarrum Posted September 9, 2012 Scripting Moderators Posted September 9, 2012 My pleasure.
Anderl Posted September 9, 2012 Posted September 9, 2012 function getGameTime ( ) local time = getRealTime ( ) local hours = time.hour local minutes = time.minute if hours < 10 then hours = "0" .. hours end return hours .. ":" .. minutes end -- outputChatBox ( getGameTime ( ) ) There is no need for that: string.format( '%02d', getRealTime().hour ) --Output: 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13 and so on.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now