Difference between revisions of "OnUpdate - Form"
m
Floatified parameters
imported>Tunaisafish m (→Notes) |
imported>JustinOther m (Floatified parameters) |
||
Line 17: | Line 17: | ||
<source lang="papyrus"> | <source lang="papyrus"> | ||
Function SomeFunction() | Function SomeFunction() | ||
RegisterForUpdate(5.0) ; Before we can use OnUpdate() we must register. | |||
EndFunction | EndFunction | ||
Event OnUpdate() ; | Event OnUpdate() ; This event occurs every five seconds | ||
If myQuest.GetStage() == 10 | |||
UnregisterForUpdate() ; when we're done with it, make sure to unregister | |||
Debug.Trace("Got what we needed, so stop polling!") | |||
EndIf | |||
EndEvent | EndEvent | ||
</source> | </source> | ||
Line 35: | Line 35: | ||
<source lang="papyrus"> | <source lang="papyrus"> | ||
Function StartChain() | Function StartChain() | ||
RegisterForSingleUpdate(1) ; Give us a single update in one second | RegisterForSingleUpdate(1.0) ; Give us a single update in one second | ||
EndFunction | |||
Event OnUpdate() | Event OnUpdate() | ||
Bool bKeepUpdating = True | |||
; Do stuff here, and update the bKeepUpdating variable depending on whether you want another update or not | |||
If bKeepUpdating | |||
RegisterForSingleUpdate(1.0) | |||
EndIf | |||
EndEvent</source> | |||
</source> | |||
This prevents multiple update events from stacking up on top of each other and slowing Papyrus down. If multiple update events do stack up on top of one another, this will also increase save file size. If ''enough'' instances of the event are stacked up in this way, it can cause significant increases in the size of any save file created. | This prevents multiple update events from stacking up on top of each other and slowing Papyrus down. If multiple update events do stack up on top of one another, this will also increase save file size. If ''enough'' instances of the event are stacked up in this way, it can cause significant increases in the size of any save file created. | ||