Two first events mainly.
This is supposed to run on ReferenceAlias script attached to Player + NPCs. Should Unregister/Re-register updates on OnLoad/OnUnload (which does not get triggered for player). OnLoad happens on every loc change for followers, what really kinda forces me to make it as short as possible.
OnLoad block - should re-register for the remaining amount of time since the last OnUnload.
OnUpdateGameTime block - should check for all missing updates after fast travel or wait.
;VARSFloat fTimeRemainingFloat fTimeCurrentFloat fTimeDesiredFloat fUpdate = 1.0 ;ReadOnlyInt iCounterEvent OnLoad() fTimeCurrent = GetHoursPassed() If ( fTimeCurrent - fTimeDesired ) > fUpdate fTimeRemaining = UpdateCheck() Else fTimeRemaining = fTimeDesired - fTimeCurrent EndIf fTimeDesired = fTimeCurrent + fTimeRemaining RegisterForSingleUpdateGameTime(fTimeRemaining) RegisterForModEvent("OnGameReload", "OnGameReload")EndEventEvent OnUpdateGameTime() fTimeCurrent = GetHoursPassed() fTimeRemaining = UpdateCheck() + fUpdate fTimeDesired = fTimeCurrent + fTimeRemaining RegisterForSingleUpdateGameTime(fTimeRemaining)EndEventEvent OnUnload() UnregisterForUpdateGameTime() UnregisterForAllModEvents()EndEventFloat Function UpdateCheck() Int iMultiplier = Floor(fTimeCurrent - fTimeDesired) / fUpdate iCounter = iMultiplier * 1 ;my value ;returns remaining value Return fTimeDesired - iMultiplier * fUpdateEndFunctionFloat Function GetHoursPassed() Return GameDaysPassed.GetValue() * 24EndFunction
I really hate this code. If you could make it shorter or make it look less "cheap" in general... Thanks in advance for any hints!