with: Difference between revisions
Lou Montana (talk | contribs) m (Text replacement - " \{\{GameCategory\|[a-z]+[0-9]?\|Scripting Commands\}\}" to "") |
Lou Montana (talk | contribs) m (Text replacement - " \| *(game[0-9]|version[0-9]|gr[0-9]|serverExec|mp|pr|descr|s[0-9]|p[0-9]{1,3}|r[0-9]|x1?[0-9]|seealso) *= +" to " |$1= ") |
||
Line 13: | Line 13: | ||
|version4= 0.50 | |version4= 0.50 | ||
|gr1= | |gr1= Program Flow | ||
|descr= Creates a [[With Type]] that is used inside a [[do]] construct in order to execute code inside a given namespace. | |descr= Creates a [[With Type]] that is used inside a [[do]] construct in order to execute code inside a given namespace. | ||
Line 61: | Line 61: | ||
To eliminate possibility of error you can also use [[setVariable]] or [[getVariable]] with desired [[Namespace]], which is also [[Scheduler#Scheduled_Environment|scheduled environment]] safe. | To eliminate possibility of error you can also use [[setVariable]] or [[getVariable]] with desired [[Namespace]], which is also [[Scheduler#Scheduled_Environment|scheduled environment]] safe. | ||
|s1= | |s1= [[with]] namespace | ||
|p1= namespace: [[Namespace]] | |p1= namespace: [[Namespace]] |
Revision as of 23:55, 19 June 2021
Description
- Description:
- Creates a With Type that is used inside a do construct in order to execute code inside a given namespace.
NOTE for the reasons unknown, namespace switching might unexpectedly occur inside some scopes (for, if, try, call) started in scheduled scripts (canSuspend true) after small suspension if with was not the main scope. For example:
To eliminate possibility of error you can also use setVariable or getVariable with desired Namespace, which is also scheduled environment safe.[] spawn { with uiNamespace do { for "_i" from 1 to 1 do { systemChat str [ currentNamespace isEqualTo uiNamespace, currentNamespace isEqualTo missionNamespace ]; // result [true, false] sleep 0.05; //<-- small suspension systemChat str [ currentNamespace isEqualTo uiNamespace, currentNamespace isEqualTo missionNamespace ]; // result [false, true] <-- switching }; }; };
However if with used in parent scope, everything works correctly:with uiNamespace do { [] spawn { for "_i" from 1 to 1 do { systemChat str [ currentNamespace isEqualTo uiNamespace, currentNamespace isEqualTo missionNamespace ]; // result [true, false] sleep 0.05; //<-- small suspension systemChat str [ currentNamespace isEqualTo uiNamespace, currentNamespace isEqualTo missionNamespace ]; // result [true, false] <-- NO switching }; }; };
- Groups:
- Program Flow
Syntax
Examples
- Example 1:
_myWithType = with uiNamespace;
- Example 2:
with missionNamespace do {global = global + 1};
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