dldrzz000 Posted January 23, 2024 Share Posted January 23, 2024 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 More sharing options...
Pickysaurus Posted January 23, 2024 Share Posted January 23, 2024 If you're worried about time errors, you might want to break out of the timer, execute the function and then re-establish it. 1 Link to comment Share on other sites More sharing options...
LarannKiar Posted January 23, 2024 Share Posted January 23, 2024 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). 1 Link to comment Share on other sites More sharing options...
dldrzz000 Posted January 25, 2024 Author Share Posted January 25, 2024 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 More sharing options...
Recommended Posts