Jump to content

Question about 2 scripts


Ghaunadaur

Recommended Posts

Hello all,

I have two simple scripts which do basically the same: an object will get disabled on activation and after a specific period of time it gets enabled again. It needs to be placed on ~20 objects. I just wonder which one I should use regarding speed, CPU usage and reliability.

 

 

Variant 1:

Scriptname script01 extends ObjectReference

int property TimeToReset auto

Event OnActivate(ObjectReference akActionRef)
disable()
RegisterForSingleUpdateGameTime(TimeToReset)
EndEvent

Event OnUpdateGameTime()
enable()
EndEvent

 

Variant 2:

Scriptname script02 extends ObjectReference

int property TimeToReset auto

Event OnActivate(ObjectReference akActionRef)
disable()
Utility.WaitGameTime(TimeToReset)
enable()
EndEvent

 

Thanks in advance for any suggestions on this!

Link to comment
Share on other sites

I think the first script would be more efficient. The running thread will terminate after the RegisterForSingleUpdateGameTime has executed, then the game engine will start a new thread only after the given time has elapsed. On the other hand, the second script will trap the running thread at the WaitGameTime function and keep that thread alive while it is waiting for the specified wait time to elapse. Edited by steve40
Link to comment
Share on other sites

  • Recently Browsing   0 members

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