Jump to content

[LE] Papyrus date help


tesfan1999

Recommended Posts

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

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...