tesfan1999 Posted November 16, 2017 Share Posted November 16, 2017 How do i detect if a single in-game day has passed? Link to comment Share on other sites More sharing options...
IsharaMeradin Posted November 17, 2017 Share Posted November 17, 2017 Store the game time when you start your day and then compare that to the current game time and determine if a day has passed. Example: ScriptName SomeScript Extends ObjectReference Float OldTime = 0.0 Bool RunOnce = false Event OnActivate(ObjectReference akActionRef) If akActionRef == Game.GetPlayer() If RunOnce == false ;initial run only If OldTime == 0.0 OldTime = Utility.GetCurrentGameTime() RunOnce = true EndIf Else ;all other runs Float NewTime = Utility.GetCurrentGameTime() If (Floor(NewTime - OldTime) >= 1) OldTime = NewTime Debug.Notification("At least one full game day has passed since last activation") Else Debug.Notification("Less than one day has passed since last activation") EndIf EndIf EndIf EndEvent Another alternative would be to register for an update event to trigger after one game day has passed. Example: Scriptname SomeScript Extends ObjectReference Bool RunOnce = false Event OnActivate(ObjectReference akActionRef) If akActionRef == Game.GetPlayer() If RunOnce == false RegisterForSingleUpdateGameTime(24.0) RunOnce = true Else Debug.Notification("less than one day has passed since last activation") EndIf EndIf EndEvent Event OnUpdateGameTime() Debug.Notification("At least one game day has passed since last activation") RunOnce = false EndEvent Link to comment Share on other sites More sharing options...
tesfan1999 Posted November 17, 2017 Author Share Posted November 17, 2017 I actually need the script to run in the background and run some commamds every time a day passes. Link to comment Share on other sites More sharing options...
IsharaMeradin Posted November 17, 2017 Share Posted November 17, 2017 Then you'll most likely want to register for the game time update. Most basic example: Scriptname SomeScript Extends Quest Event OnInit() RegisterForSingleUpdateGameTime(24.0) Debug.Notification("Registered for update in one game day") EndEvent Event OnUpdateGameTime() Debug.Notification("At least one game day has passed") RegisterForSingleUpdateGameTime(24.0) Debug.Notification("Registered for update in one game day") EndEvent There are things to consider. If the user is sleeping or waiting when the update should take place, the update won't happen until after they finish sleeping or waiting. Depending upon what you want to do, that may or may not be an issue. Link to comment Share on other sites More sharing options...
tesfan1999 Posted November 18, 2017 Author Share Posted November 18, 2017 All right, thanks. I will try this. Meanwhile, feel free to check out my mod: https://www.nexusmods.com/skyrim/mods/87750/? Link to comment Share on other sites More sharing options...
Recommended Posts