Difference between revisions of "User:DavidJCobb/Stack dumping"
m
→Code snippets: combined two functionally-identical snippets
imported>DavidJCobb (→Code snippets: More snippets, and explanations for all snippets.) |
imported>DavidJCobb m (→Code snippets: combined two functionally-identical snippets) |
||
Line 40: | Line 40: | ||
* RegisterForSingleUpdate(''n'') does ''not'' create a stack and suspend it for ''n'' seconds. I have confirmed this experimentally. | * RegisterForSingleUpdate(''n'') does ''not'' create a stack and suspend it for ''n'' seconds. I have confirmed this experimentally. | ||
=== Process a task OnHit, and wait for X seconds during or after the task === | |||
=== Process a task OnHit, and wait for X seconds during the task === | |||
This simple example blocks concurrent calls, and replaces a Utility.Wait(X) call with a RegisterForSingleUpdate(X) call. If we used Utility.Wait(X), we'd suspend our stack for X seconds; by using RegisterForSingleUpdate and OnUpdate, we get rid of the stack entirely during those X seconds, and create a new stack to continue processing after the delay. | This simple example blocks concurrent calls, and replaces a Utility.Wait(X) call with a RegisterForSingleUpdate(X) call. If we used Utility.Wait(X), we'd suspend our stack for X seconds; by using RegisterForSingleUpdate and OnUpdate, we get rid of the stack entirely during those X seconds, and create a new stack to continue processing after the delay. | ||
Line 74: | Line 47: | ||
Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, Bool abPowerAttack, Bool abSneakAttack, Bool abBashAttack, Bool abHitBlocked) | Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, Bool abPowerAttack, Bool abSneakAttack, Bool abBashAttack, Bool abHitBlocked) | ||
If pbBusy | If pbBusy | ||
Return | Return | ||
EndIf | EndIf | ||
Line 86: | Line 59: | ||
Event OnUpdate() | Event OnUpdate() | ||
; | ; | ||
; Continue processing here. | ; Continue processing here (or do nothing, if your goal was to wait X seconds after processing a task before allowing more tasks to be processed). | ||
; | ; | ||
pbBusy = False ; We're done! | pbBusy = False ; We're done! |