{"name":"Namespace","title":"Namespace","type":"topic","url":"https://community.bistudio.com/wiki/Namespace","revid":369024,"updated":"2024-08-26T13:59:25Z","aliases":[],"markdown":"Arma 2 v1.00\n\nA Namespace is a container for Variables.\nAny global variable is always part of exactly one namespace - another namespace may contain a variable with the same Identifier, but they remain two distinct independent variables.\nScripts and functions are always executed in the context of some namespace.\n\nThe default namespace is the missionNamespace.\n\n### Namespaces\n\n| Game | Namespace | Description | Lifetime |\n|---|---|---|---|\n| Arma 2 v1.00 | missionNamespace | The global namespace of the mission. Every mission has its own missionNamespace. | Mission duration |\n| Arma 2 v1.00 | parsingNamespace | The global namespace attached to the Config Parser. | Game session |\n| Arma 2 v1.00 | uiNamespace | The global namespace attached to the user interface. | Game session |\n| Take On Helicopters v1.00 | profileNamespace | The global namespace attached to the user profile. | Profile lifetime |\n| Arma 3 v2.00 | localNamespace | This namespace is like the missionNamespace, except that its variables can not be sent over network (e.g. with publicVariable) or serialised. | Mission duration |\n| Arma 3 v2.06 | serverNamespace | The namespace used by Server Event Handlers. This namespace is only available on servers. | Game session |\n| Arma 3 v2.10 | missionProfileNamespace | This namespace is like profileNamespace but is also attached to a missionName or missionGroup. Automatically loaded before init.sqf. | Profile lifetime |\n\n### Serialisation\n\nOnly the missionNamespace is serialised, as in only the variables from this namespace are saved when the game is saved (e.g. with saveGame) and loaded when the game is loaded (e.g. with loadGame).\nThis 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 exempt from serialisation by default.\n\n### Scripting\n\nInteracting with namespaces is not difficult:\n- The getVariable and setVariable commands can be used to work with variables from different namespaces.\n- The with-do construct can be used to switch the context of an entire code block to another namespace.\n- The currentNamespace command can be used to obtain the namespace which the calling script is running in.","sections":[{"heading":null,"level":1,"markdown":"Arma 2 v1.00\n\nA Namespace is a container for Variables.\nAny global variable is always part of exactly one namespace - another namespace may contain a variable with the same Identifier, but they remain two distinct independent variables.\nScripts and functions are always executed in the context of some namespace.\n\nThe default namespace is the missionNamespace."},{"heading":"Namespaces","level":3,"markdown":"| Game | Namespace | Description | Lifetime |\n|---|---|---|---|\n| Arma 2 v1.00 | missionNamespace | The global namespace of the mission. Every mission has its own missionNamespace. | Mission duration |\n| Arma 2 v1.00 | parsingNamespace | The global namespace attached to the Config Parser. | Game session |\n| Arma 2 v1.00 | uiNamespace | The global namespace attached to the user interface. | Game session |\n| Take On Helicopters v1.00 | profileNamespace | The global namespace attached to the user profile. | Profile lifetime |\n| Arma 3 v2.00 | localNamespace | This namespace is like the missionNamespace, except that its variables can not be sent over network (e.g. with publicVariable) or serialised. | Mission duration |\n| Arma 3 v2.06 | serverNamespace | The namespace used by Server Event Handlers. This namespace is only available on servers. | Game session |\n| Arma 3 v2.10 | missionProfileNamespace | This namespace is like profileNamespace but is also attached to a missionName or missionGroup. Automatically loaded before init.sqf. | Profile lifetime |"},{"heading":"Serialisation","level":3,"markdown":"Only the missionNamespace is serialised, as in only the variables from this namespace are saved when the game is saved (e.g. with saveGame) and loaded when the game is loaded (e.g. with loadGame).\nThis 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 exempt from serialisation by default."},{"heading":"Scripting","level":3,"markdown":"Interacting with namespaces is not difficult:\n- The getVariable and setVariable commands can be used to work with variables from different namespaces.\n- The with-do construct can be used to switch the context of an entire code block to another namespace.\n- The currentNamespace command can be used to obtain the namespace which the calling script is running in."}],"categories":["Data Types","Introduced with Arma 2 version 1.00"],"groups":["Data Types"]}