Difference between revisions of "User:Rasikko"

2,794 bytes removed ,  09:31, 29 June 2018
no edit summary
imported>Rasikko
m (Undo revision 51770 by Rasikko (talk)impossible to make edits on a phone.)
imported>Rasikko
Line 54: Line 54:
FT = Unit * 0.046875 --[[User:Rasikko|Rasikko]] ([[User talk:Rasikko|talk]]) 2018-01-10T12:18:45 (EST)
FT = Unit * 0.046875 --[[User:Rasikko|Rasikko]] ([[User talk:Rasikko|talk]]) 2018-01-10T12:18:45 (EST)


== Time Functions ==
Various functions for calculating time in skyrim. Most use [[GetCurrentGameTime - Utility]] as it returns the total game days passed. Making it easier for conversions.<br><br>
This function has GetCurrentGameTime live up to its name. Will return the in-game time, instead of days passed. At least 1 day has to have passed.
<source lang="papyrus">
Float Function GetCurrentGameTimeExtended() Global
    ; Returns the time displayed in the game.
    ; Format is hh.mmssss
    Float currentGameTime = Utility.GetCurrentGameTime()
    Float fractionOfDay = currentGameTime - currentGameTime as int
    Float hour = (fractionOfDay * 24) as int
    Float minutes = ((fractionOfDay * 24) - hour) * 60
    Float seconds = (minutes - minutes as int) * 60
    if currentGameTime >= 1.0
; before adding the hours, we need to turn the minutes into a decimal.
minutes = (minutes as int) / 100.0
; do the same to the seconds
seconds = seconds / 10000.0
return hour + minutes + seconds
    endif
    return -1.0
EndFunction
</source>
<br/>
This simple function converts days passed into hours passed.
<source lang="papyrus">
Float Function GetGameHoursPassed()
; Converts the game days passed to game time hours.
return Utility.GetCurrentGameTime() * 24
EndFunction
</source>
<br />
This function takes the game days passed and converts them into minutes passed.
<source lang="papyrus">
Float Function GetGameMinutesPassed()
    ; Converts the game days passed to game minutes passed.
    return Utility.GetCurrentGameTime() * 24 * 60
EndFunction
</source>
<br/>
To get the total ''real'' minutes passed since the game started, you do the following:<br>
<source lang="papyrus">
Game.GetRealHoursPassed() * 60
</source>
<br/>
To get the number of seconds that have passed since game start. Note at least 1 day has to have passed:
<source lang="papyrus">
Float Function GetGameSecondsPassed()
    ; returns the number of game seconds since game start.
    Float gameTime = Utility.GetCurrentGameTime()
    if gameTime >= 1.0
return gameTime / 24.0 * 60 * 60
    endif
    return -1.0
EndFunction
</source>
<br/>
For milliseconds:
<source lang="papyrus">
Float Function GetGameMillisecondsPassed()
    ; Returns milliseconds passed since game start.
    Float gameTime = Utility.GetCurrentGameTime()
    if gameTime >= 1.0
return gameTime / 24.0 * 60.0 * 60.0 * 1000.0
    endif
    return -1.0
EndFunction
</source>
Short note about game time: Game time is paused when in a menu. While this is a well known fact, it can be easily forgotten when working with it along side real time, as real time obviously keeps running.
<br><br>
Skyrim has no leap years, and thus has common years, where the first day and last day of the year are on the same day of the week.


== Calendar Functions ==
== Calendar Functions ==
Anonymous user