Difference between revisions of "User:Rasikko"

From the CreationKit Wiki
Jump to navigation Jump to search
imported>Rasikko
m
imported>Rasikko
m
Line 53: Line 53:
EndFunction
EndFunction
</source>
</source>
Note: The functio may be faster to use the GameDay global as a property and simply call GetValue on it than using [[GetFormFromFile - Game]] and reduce number of casting. I used GetFormFromFile simply because it keeps my code(s) as small as possible on this page.
Note: The function may be faster to use the GameDay global as a property and simply call GetValue on it than using [[GetFormFromFile - Game]] and reduce number of casting. I used GetFormFromFile simply because it keeps my code(s) as small as possible on this page.

Revision as of 12:39, 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.

Float Function GetGameHoursPassed()
	; Converts the game days passed to game time hours.
	return Utility.GetCurrentGameTime() * 24
EndFunction


This function takes the game days passed and converts them into minutes passed.

Float Function GetGameMinutesPassed()
    ; Converts the game days passed to game minutes passed.
    return Utility.GetCurrentGameTime() * 24 * 60
EndFunction


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.

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


To get the total real minutes passed since the game started, you do the following:

Game.GetRealHoursPassed() * 60


To get the total game minutes passed since the game started, you do the following:

(Game.GetRealHoursPassed() * 60) / (Game.GetFormFromFile(0x0000003A, "Skyrim.ESM") as GlobalVariable).GetValue() ; Timescale global


To get the total game hours passed since a game month has started:

Float Function GetGameHoursPassedForMonth()
    ; Returns the number of hours passed for the current month.
    Float CurrentGameTime = Utility.GetCurrentGameTime()
    return (((Game.GetFormFromFile(0x0000037, "Skyrim.ESM") as GlobalVariable).GetValue() * 24) + ((CurrentGameTime - CurrentGameTime as int) * 24)) as Float
EndFunction

Note: The function may be faster to use the GameDay global as a property and simply call GetValue on it than using GetFormFromFile - Game and reduce number of casting. I used GetFormFromFile simply because it keeps my code(s) as small as possible on this page.