Jump to content

A newbie question about time-related papyrus functions/events like Registerforsingleupdate()/OnUpdate() in Skyrim and StartTimerGameTime()/OnTimerGameTime() in FO4.


dldrzz000

Recommended Posts

Greetings. I recently have some ideas for a survival mod, but I am just pondering on possible time errors caused by frame-bounded functions inside recycling time functions and events. 

For example: 

Event OnTimerGameTime()

        BatchFunction_001()

        StartTimerGameTime(x, 0)

End Event

BatchFunction_001 contains some frame-bounded functions like GetActorValue() and GetLocation(). Will this structure beget accumulated minor time errors?

Link to comment
Share on other sites

The code snippet you posted would restart the GameTime timer once BatchFunction() is executed.

If precision is a priority you'll probably want to get the current game time with a function like this, then restart your timer accordingly.

Float Function GetCurrentTime()
	Float CurrentTime = Utility.GetCurrentGameTime()
	CurrentTime = CurrentTime - Math.Floor(CurrentTime)
	CurrentTime = CurrentTime*24
	Return CurrentTime
EndFunction

Defining the function BatchFunction() in another script then sending a CustomEvent from the GameTime timer is also an option, if you'd like to untie the execution of BatchFunction() and the GameTimer ("untie": at least as much as the Virtual Machine allows it as for example heavy script load can slow down the entire system which of course affects the execution of other scripts).

  • Thanks 1
Link to comment
Share on other sites

On 1/23/2024 at 4:39 PM, Pickysaurus said:

If you're worried about time errors, you might want to break out of the timer, execute the function and then re-establish it. 

 

On 1/23/2024 at 7:13 PM, LarannKiar said:

The code snippet you posted would restart the GameTime timer once BatchFunction() is executed.

If precision is a priority you'll probably want to get the current game time with a function like this, then restart your timer accordingly.

Float Function GetCurrentTime()
	Float CurrentTime = Utility.GetCurrentGameTime()
	CurrentTime = CurrentTime - Math.Floor(CurrentTime)
	CurrentTime = CurrentTime*24
	Return CurrentTime
EndFunction

Defining the function BatchFunction() in another script then sending a CustomEvent from the GameTime timer is also an option, if you'd like to untie the execution of BatchFunction() and the GameTimer ("untie": at least as much as the Virtual Machine allows it as for example heavy script load can slow down the entire system which of course affects the execution of other scripts).

Thank you both! Issue solved.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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