canSuspend: Difference between revisions
Jump to navigation
Jump to search
Lou Montana (talk | contribs) m (Text replacement - "(\| * )+\}\}" to "}}") |
Lou Montana (talk | contribs) m (Text replacement - " {3,}" to " ") |
||
Line 5: | Line 5: | ||
|gr2= Program Flow | |gr2= Program Flow | ||
| Returns [[true]] if [[sleep]], [[uiSleep]] or [[waitUntil]] commands can be used in current scope. Usually when suspension is not allowed but used, for example when code is executed in [[Scheduler#Unscheduled_Environment|unscheduled environment]], the script engine would ignore any suspension command and throw error: "Suspending not allowed in this context". Using [[canSuspend]] command allows to detect the correct environment for the code. | | Returns [[true]] if [[sleep]], [[uiSleep]] or [[waitUntil]] commands can be used in current scope. Usually when suspension is not allowed but used, for example when code is executed in [[Scheduler#Unscheduled_Environment|unscheduled environment]], the script engine would ignore any suspension command and throw error: "Suspending not allowed in this context". Using [[canSuspend]] command allows to detect the correct environment for the code. | ||
<br><br>{{Informative |The definition of [[Scheduler#Scheduled_Environment|scheduled]] and [[Scheduler#Unscheduled_Environment|unscheduled environment]] is not the same as whether or not the script execution can or cannot be suspended. For example while .''sqs'' and .''fsm'' scripts are [[Scheduler#Scheduled_Environment|scheduled]] (i.e. added to the [[Scheduler|scheduler]]: [[diag_activeSQSScripts]], [[diag_activeMissionFSMs]]), they cannot use [[sleep]] or be suspended like [[execVM]] or [[spawn]] scripts can, therefore [[canSuspend]] for these types of scripts will return [[false]]. }} | <br><br>{{Informative |The definition of [[Scheduler#Scheduled_Environment|scheduled]] and [[Scheduler#Unscheduled_Environment|unscheduled environment]] is not the same as whether or not the script execution can or cannot be suspended. For example while .''sqs'' and .''fsm'' scripts are [[Scheduler#Scheduled_Environment|scheduled]] (i.e. added to the [[Scheduler|scheduler]]: [[diag_activeSQSScripts]], [[diag_activeMissionFSMs]]), they cannot use [[sleep]] or be suspended like [[execVM]] or [[spawn]] scripts can, therefore [[canSuspend]] for these types of scripts will return [[false]]. }} | ||
| '''canSuspend''' | | '''canSuspend''' | ||
| [[Boolean]] | | [[Boolean]] | ||
|x1= <code>[[onEachFrame]] | |x1= <code>[[onEachFrame]] | ||
Line 31: | Line 28: | ||
5 [[call]] mysleep;</code> | 5 [[call]] mysleep;</code> | ||
| [[sleep]], [[uiSleep]], [[waitUntil]], [[call]], [[spawn]], [[execVM]], [[isRemoteExecuted]], [[isRemoteExecutedJIP]], [[remoteExecutedOwner]], [[isUIContext]], [[isGamePaused]], [[isGameFocused]] | | [[sleep]], [[uiSleep]], [[waitUntil]], [[call]], [[spawn]], [[execVM]], [[isRemoteExecuted]], [[isRemoteExecutedJIP]], [[remoteExecutedOwner]], [[isUIContext]], [[isGamePaused]], [[isGameFocused]] | ||
}} | }} | ||
{{GameCategory|arma3|New Scripting Commands}} | {{GameCategory|arma3|New Scripting Commands}} | ||
{{GameCategory|arma3|Scripting Commands}} | {{GameCategory|arma3|Scripting Commands}} | ||
[[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]] | [[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]] |
Revision as of 16:59, 18 January 2021
Description
- Description:
- Returns true if sleep, uiSleep or waitUntil commands can be used in current scope. Usually when suspension is not allowed but used, for example when code is executed in unscheduled environment, the script engine would ignore any suspension command and throw error: "Suspending not allowed in this context". Using canSuspend command allows to detect the correct environment for the code.
- Groups:
- Program Flow
Syntax
- Syntax:
- canSuspend
- Return Value:
- Boolean
Examples
- Example 1:
onEachFrame { systemChat str canSuspend; //false [] spawn {hint str canSuspend}; //true onEachFrame {}; };
- Example 2:
- Make sure the function code is always spawned even when called:
mysleep = { if (!canSuspend) exitWith {_this spawn mysleep}; sleep _this; hint ("slept " + str _this); }; 5 call mysleep;
Additional Information
- See also:
- sleepuiSleepwaitUntilcallspawnexecVMisRemoteExecutedisRemoteExecutedJIPremoteExecutedOwnerisUIContextisGamePausedisGameFocused
Notes
-
Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note