Talk:GetCurrentGameTime - Utility

Active discussions

GetRealCurrentGameTimeEdit

Float Function GetRealCurrentGameTime()
	; Returns the current time seen in the wait, sleep, and journal menus.
	
        ; Store the current days passed.
        Float getCurrentTime = Utility.GetCurrentGameTime()
	
	; Get the current real hour in game time.
	Float getRealCurrentGameHour = ((getCurrentTime - getCurrentTime as int) * 24) as int
	
        ; Get the current real minutes of the real game time hour, but removing the hour.
	Float getRealCurrentGameMinutes = ((getCurrentTime - getCurrentTime as int) * 24) - ((getCurrentTime - getCurrentTime as int) * 24) as int
	
        ; Add the current real minutes to the current real game time hour.
	Float getRealCurrentGameHoursMinutes = getRealCurrentGameHour + ((getRealCurrentGameMinutes * 60) + 1) / 100
	
       	return getRealCurrentGameHoursMinutes 
	
EndFunction

I'll explain this the best I can, there's a bit of math involved and I'm bad at explaining math. The time you see in the wait, journal, and sleep menus is calculated differently than the 'time' returned from GetCurrentGameTime and/or using the globalvariable GameDaysPassed(with some math). If it's 9:32AM, the game will convert it as 9.52xxxx, with xxxx possibly being the seconds(a value I don't know how to get, since there's no function to chop off specific decimal points. This function I made will convert, for example, 9.52 into 9.32. There's some rounding involved as well. —The preceding unsigned comment was added by Lisselli (talkcontribs) 2017-09-11T08:41:01

GetCurrentRealGameSecondsEdit

Float Function GetCurrentRealGameSeconds()
	; returns the current game time in seconds.
	
	; Days passed: Example: 88.325645
	Float getCurrentTime = Utility.GetCurrentGameTime()
	
	; Days passed to part of the current day as a fraction.
	; Example: 88.325645 - 88.000000 = 0.325645
	Float getFractionOfDay = getCurrentTime - getCurrentTime as int
		
	; Fraction of day to current hours and minutes(as a float)
	; Exampple: 0.325645 x 24 = 7.815480
	Float getTimeOfDay = getFractionOfDay * 24
		
	; Convert hours and minutes(as a float) to the fraction of an hour.
	; Example: 7.815480 - 7.000000 = 0.815480
	Float getFractionOfHour =  (getTimeOfDay - getTimeOfDay as int)
	
	; Convert to real minutes.
	; Example: 0.815480 * 60 + = 48.928800
	Float getRealMinutes = (getFractionOfHour * 60)
		
	; Remove minutes from the seconds.
	; Example: 48.928800 - 48.000000
	Float getFractionOfMinutes = getRealMinutes - getRealMinutes as int
		
	; Convert to real seconds.
	; Example: 0.928800 * 60 = 55.728
	Float getRealSeconds = (getFractionOfMinutes * 60) as int
		
	; Current Game Time: 7:48:55 AM
	
	return getRealSeconds
EndFunction

My GetRealCurrentGameTime() function was expanded upon a bit, and I've been able to get the seconds as well. Both functions use the concept supplied by another function GetTimeOfDay. I put in some examples to show how the function works as its gets down to calculating the real game seconds. Note that when I say 'real', I'm talking about the real time format used in the menus. Seconds though is not shown. —The preceding unsigned comment was added by Lisselli (talkcontribs) 2017-09-11T08:41:01

Return to "GetCurrentGameTime - Utility" page.