Difference between revisions of "User:Rasikko"
imported>Scrivener07 |
imported>Scrivener07 |
||
Line 61: | Line 61: | ||
</source> | </source> | ||
<br> | <br> | ||
Functions for returning units of time since 10.28.2287. 30.416667 is used because Fallout 4 does not have leap years and thus always has common years(365 days). | |||
<source lang="papyrus"> | <source lang="papyrus"> | ||
Float Function GetMonthsPassed(Float afDaysPassed) Global | Float Function GetMonthsPassed(Float afDaysPassed) Global | ||
; Returns the number of month passed since game start. | ; Returns the number of month passed since game start. |
Revision as of 14:43, 31 August 2018
Time Functions
These are some helper functions you can use to work with time in the game. I offer three ways of starting them off, as the functions will require any of the three methods.
The first method is through GetCurrentGameTime - Utility. It does the same thing as the Global GameDaysPassed only a little slower.
Float daysPassed = Utility.GetCurrentGameTime()
The second method is through the global.
GlobalVariable property GameDaysPassed auto
The last method is through GetFormFromFile and pulls the global instead of making it a property.
Float daysPassed = (Game.GetFormFromFile(0x00000039, "Fallout4.ESM") as GlobalVariable).GetValue()
Using any of them, you pass into the arguments where needed for the following function:
Float Function GetGameTime(Float afDaysPassed) Global
; Returns the number of hours passed for the current day.
Float gameTime = (afDaysPassed - afDaysPassed as int) * 24.0
if gameTime > 12.00
return gameTime - 12.00
endif
return gameTime
EndFunction
This function requires the return value from GetGameTime() above.
Float Function GetCurrentInGameTime(Float afGameTime) Global
; Returns the actual in game time. h.mm0000
return afGameTime as int + ((((afGameTime - afGameTime as int) * 60.0) as int) / 100.0)
EndFunction
String Function GetCurrentDayOfWeek(Float afDaysPassed) Global
; Returns the day of week. Returns an empty string if something went wrong.
Int dayOfWeek = afDaysPassed as int % 7
if dayOfWeek == 0
return "Sunday"
elseif dayOfWeek == 1
return "Monday"
elseif dayOfWeek == 2
return "Tuesday"
elseif dayOfWeek == 3
return "Wednesday"
elseif dayOfWeek == 4
return "Thursday"
elseif dayOfWeek == 5
return "Friday"
elseif dayOfWeek == 6
return "Saturday"
endif
return ""
EndFunction
Functions for returning units of time since 10.28.2287. 30.416667 is used because Fallout 4 does not have leap years and thus always has common years(365 days).
Float Function GetMonthsPassed(Float afDaysPassed) Global
; Returns the number of month passed since game start.
return afDaysPassed / 30.416667
EndFunction
Float Function GetWeeksPassed(Float afDaysPassed) Global
; Returns the number of weeks passed since game start.
return afDaysPassed / 7
EndFunction
Float Function GetTotalHoursPassed(Float afDaysPassed) Global
; Returns the total number of hours passed since game start.
return afDaysPassed * 24.0
EndFunction
Float Function GetTotalMinutesPassed(Float afDaysPassed) Global
; Returns the total number of minutes passed since game start.
return afDaysPassed * 24.0 * 60.0
EndFunction
Float Function GetTotalSecondsPassed(Float afDaysPassed) Global
; Returns the total number of seconds passed since game start.
return afDaysPassed * 24.0 * 60 * 60.0
EndFunction