Difference between revisions of "GetCurrentRealTime - Utility"

From the Fallout4 CreationKit Wiki
Jump to navigation Jump to search
imported>Scrivener07
m (→‎Examples: added example to get the current time of the day.)
imported>Scrivener07
(Undo revision 10199 by Rasikko (talk) I got confused between this and GetCurrentGameTime)
 
Line 23: Line 23:
float ftimeEnd = Utility.GetCurrentRealTime()
float ftimeEnd = Utility.GetCurrentRealTime()
Debug.Trace("We took " + (ftimeEnd - ftimeStart) + " seconds to run")
Debug.Trace("We took " + (ftimeEnd - ftimeStart) + " seconds to run")
</source>
<br>
<source lang="papyrus">
Float Function GetCurrentTimeOfDay()
; Returns the current time in hours. Fractional part is seconds.
; This can be furthered to get minutes, milliseconds, etc.
Float daysPassed = Utility.GetCurrentGameTime()
; remove the days passed and return the current time of the day.
return (daysPassed - daysPassed as int) * 24.0
EndFunction
</source>
</source>



Latest revision as of 07:51, 6 June 2018

Member of: Utility Script

Gets the number of real-world seconds that have elapsed since the game has launched. This time does not count time the game has been alt-tabbed, or other cases where the game has been frozen (i.e. during a save or load, time in a menu is counted). This function is most useful for timing a long operation.

Syntax[edit | edit source]

float Function GetCurrentRealTime() native

Parameters[edit | edit source]

None.

Return Value[edit | edit source]

The number of seconds since the game has been launched.

Examples[edit | edit source]

; How long does our operation take?
float ftimeStart = Utility.GetCurrentRealTime()
; Long operation here
float ftimeEnd = Utility.GetCurrentRealTime()
Debug.Trace("We took " + (ftimeEnd - ftimeStart) + " seconds to run")

See Also[edit | edit source]