Difference between revisions of "User:Rasikko"
imported>Rasikko (Created page with "I've been modding my games since TES 3.") |
imported>Rasikko (Adding some helpful time functions.) |
||
Line 1: | Line 1: | ||
I've been modding my games since TES 3. | I've been modding my games since TES 3. | ||
== 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> | |||
This simple function converts days passed into hours passed. | |||
<source="papyrus"> | |||
Float Function GetGameHoursPassed() | |||
; Converts the game days passed to game time hours. | |||
return Utility.GetCurrentGameTime() * 24 | |||
EndFunction | |||
</source> | |||
<br /> | |||
This function does a few mathematical steps before arriving to the result:<br> | |||
1. The days passed is turned into a whole number and divided by 7 with the remainder being the day of the week.<br> | |||
2. The days passed is turned into a fraction of a day and then converted into the hours passed since that day started.<br> | |||
3. Result from Step 2 is added to the result of Step 1.<br> | |||
<source="papyrus"> | |||
Float Function GetGameHoursPassedForWeek() | |||
; returns the total hours passed for the current week. | |||
; Get the current time(it's actually how many game days have passed). | |||
Float CurrentGameTime = Utility.GetCurrentGameTime() | |||
; Get hours passed since sundas. | |||
return (((CurrentGameTime as Int) % 7) + ((CurrentGameTime - CurrentGameTime as int) * 24)) as Float | |||
EndFunction | |||
</source> |
Revision as of 09:27, 27 November 2017
I've been modding my games since TES 3.
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.
This simple function converts days passed into hours passed.
<source="papyrus">
Float Function GetGameHoursPassed()
; Converts the game days passed to game time hours.
return Utility.GetCurrentGameTime() * 24
EndFunction
</source>
This function does a few mathematical steps before arriving to the result:
1. The days passed is turned into a whole number and divided by 7 with the remainder being the day of the week.
2. The days passed is turned into a fraction of a day and then converted into the hours passed since that day started.
3. Result from Step 2 is added to the result of Step 1.
<source="papyrus">
Float Function GetGameHoursPassedForWeek()
; returns the total hours passed for the current week.
; Get the current time(it's actually how many game days have passed). Float CurrentGameTime = Utility.GetCurrentGameTime()
; Get hours passed since sundas. return (((CurrentGameTime as Int) % 7) + ((CurrentGameTime - CurrentGameTime as int) * 24)) as Float EndFunction </source>