Namespace: Difference between revisions
Killzone Kid (talk | contribs) (serialization) |
Lou Montana (talk | contribs) m (Fix formatting and category) |
||
Line 1: | Line 1: | ||
{{SideTOC}} | |||
{{quote|a namespace is a set of symbols that are used to organize objects of various kinds, so that these objects may be referred to by name. A namespace ensures that all the identifiers within it have unique names so that they can be easily identified.|Wikipedia|https://en.wikipedia.org/wiki/Namespace}} | {{quote|a namespace is a set of symbols that are used to organize objects of various kinds, so that these objects may be referred to by name. A namespace ensures that all the identifiers within it have unique names so that they can be easily identified.|Wikipedia|https://en.wikipedia.org/wiki/Namespace}} | ||
Namespace - set of variables. Introduced with {{arma2}}. | Namespace - set of variables. Introduced with {{GVI|arma2|1.00|categorise}}. | ||
Line 32: | Line 33: | ||
To set data to a namespace, there're two methods to do: | To set data to a namespace, there're two methods to do: | ||
<code>'''namespace''' [[setVariable]] ["variableName", | <code>'''namespace''' [[setVariable]] ["variableName", ''value''];</code> | ||
<code>[[with]] '''namespace''' do { | <code>[[with]] '''namespace''' do { | ||
variableName = | variableName = ''value''; | ||
};</code> | };</code> | ||
[[missionNamespace]] is the default global namespace, so just "variableName = | [[missionNamespace]] is the default global namespace, so just "variableName = ''value'';" will store data to [[missionNamespace]]. | ||
== Namespace | |||
== Namespace Lifetimes == | |||
=== missionNamespace === | === missionNamespace === | ||
Line 53: | Line 55: | ||
This namespace will hold variables for a very long time and are attached to the user profile. Different profiles will have own set of variables stored with them. The saving of the profile namespace is forced with [[saveProfileNamespace]] command, but in Arma 3 this command is executed by vanilla game scripts already, so saving is done automatically. | This namespace will hold variables for a very long time and are attached to the user profile. Different profiles will have own set of variables stored with them. The saving of the profile namespace is forced with [[saveProfileNamespace]] command, but in Arma 3 this command is executed by vanilla game scripts already, so saving is done automatically. | ||
== Namespace serialization == | == Namespace serialization == | ||
Only [[missionNamespace]] is serialized. This means that all variables in this namespace will be saved when the game is saved and loaded when the game is loaded. This is also the reason the game will complain that one should use [[disableSerialization]] when storing UI variables in [[missionNamespace]]. UI elements are temporary and therefore are exempt from serialization by default. | Only [[missionNamespace]] is serialized. This means that all variables in this namespace will be saved when the game is saved and loaded when the game is loaded. This is also the reason the game will complain that one should use [[disableSerialization]] when storing UI variables in [[missionNamespace]]. UI elements are temporary and therefore are exempt from serialization by default. | ||
[[Category: Data Types]] | [[Category: Data Types]] |
Revision as of 12:20, 9 July 2020
Template:SideTOC Template:quote
Namespace - set of variables. Introduced with 1.00.
Get namespace
These commands return the "Namespace" type:
Game | Command | Description |
---|---|---|
1.00 | missionNamespace | returns the global namespace attached to the mission |
1.00 | parsingNamespace | returns the global namespace attached to the Config Parser |
1.00 | uiNamespace | returns the global namespace attached to the user interface |
1.00 | profileNamespace | returns the global namespace attached to the user profile |
1.48 | currentNamespace | returns the current namespace. Can be compared with isEqualTo. |
You can save values in this different Namespaces without overwriting the variables with the same name.
Get namespace data
You can use the above with getVariable to get data.
Set namespace data
To set data to a namespace, there're two methods to do:
namespace setVariable ["variableName", value];
with namespace do {
variableName = value;
};
missionNamespace is the default global namespace, so just "variableName = value;" will store data to missionNamespace.
Namespace Lifetimes
missionNamespace
Mission namespace is the main default partition that exists for the duration of a mission. All variables defined in mission namespace will cease to exist when mission ends. To make variables lasting longer than a mission, use different namespaces.
uiNamespace and parsingNamespace
These are 2 different namespaces, which have similar scope. Variables defined in these namespaces exist for the duration of the game .exe running and are lost when the game is shut down.
profileNamespace
This namespace will hold variables for a very long time and are attached to the user profile. Different profiles will have own set of variables stored with them. The saving of the profile namespace is forced with saveProfileNamespace command, but in Arma 3 this command is executed by vanilla game scripts already, so saving is done automatically.
Namespace serialization
Only missionNamespace is serialized. This means that all variables in this namespace will be saved when the game is saved and loaded when the game is loaded. This is also the reason the game will complain that one should use disableSerialization when storing UI variables in missionNamespace. UI elements are temporary and therefore are exempt from serialization by default.