Difference between revisions of "Function for Time of Day"

From the CreationKit Wiki
Jump to navigation Jump to search
imported>Daemonjax
(Created page with "returns: 0 <= return_value < 24 i.e. Midnight is 0, noon is 12, and 5:30 PM is 17.5 ---- Float FUNCTION getCurrentHourOfDay() float temp = Utility.GetCurrentGameTime() *...")
 
imported>Vitamant
m (Added languages menu)
 
(5 intermediate revisions by 3 users not shown)
Line 1: Line 1:
returns:   0 <= return_value < 24
[[Category:Solutions]]
i.e. Midnight is 0, noon is 12, and 5:30 PM is 17.5
 
The global function [[GetCurrentGameTime - Utility|GetCurrentGameTime]] can be used to return the number of in-game days passed, including the fraction of the current day that has passed.
 
This function removes the portion of GetCurrentGameTime's return value that returns to previous in-game days, then converts the remaining portion to hours.


----
----


Float FUNCTION getCurrentHourOfDay()  
<source lang="papyrus">
float Function GetCurrentHourOfDay()  


float temp = Utility.GetCurrentGameTime() * 24  
float Time = Utility.GetCurrentGameTime()
Time -= Math.Floor(Time) ; Remove "previous in-game days passed" bit
Time *= 24 ; Convert from fraction of a day to number of hours
Return Time


return ((temp as int) % 24) + (temp - (temp as int))
EndFunction
</source>


ENDFUNCTION
{{Languages}}

Latest revision as of 09:00, 7 April 2012


The global function GetCurrentGameTime can be used to return the number of in-game days passed, including the fraction of the current day that has passed.

This function removes the portion of GetCurrentGameTime's return value that returns to previous in-game days, then converts the remaining portion to hours.


float Function GetCurrentHourOfDay() 

	float Time = Utility.GetCurrentGameTime()
	Time -= Math.Floor(Time) ; Remove "previous in-game days passed" bit
	Time *= 24 ; Convert from fraction of a day to number of hours
	Return Time

EndFunction


Language: English  • русский