canSuspend: Difference between revisions
Jump to navigation
Jump to search
Killzone Kid (talk | contribs) (Created page with "{{Command|= Comments ____________________________________________________________________________________________ | arma3dev |= Game name |1.57|= Game version _____________...") |
Killzone Kid (talk | contribs) (disambiguation) |
||
Line 9: | Line 9: | ||
| 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. | | 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. | ||
<br><br>'''Note''': The definition of scheduled and unscheduled environment is not the same as whether or not the script execution can or cannot be suspended. For example .''sqs'' and .''fsm'' scripts are scheduled (i.e. added to the 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]]. | |||
|= Description | |= Description | ||
____________________________________________________________________________________________ | ____________________________________________________________________________________________ |
Revision as of 16:41, 20 March 2016
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.
Note: The definition of scheduled and unscheduled environment is not the same as whether or not the script execution can or cannot be suspended. For example .sqs and .fsm scripts are scheduled (i.e. added to the 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. - Groups:
- Uncategorised
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
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
[[Category:Introduced with arma3dev version 1.57]][[ Category: arma3dev: New Scripting Commands | CANSUSPEND]][[ Category: arma3dev: Scripting Commands | CANSUSPEND]]