Page tree
Skip to end of metadata
Go to start of metadata

A namespace is an abstract container that can be used to setVariable over specific scopes.

Variables set in one namespace are not available in others, so the same variable name can be used in different namespaces.

  • missionNamespace: Retains content while in the same mission, or upon mission restores. Content gets lost upon mission restarts or retries.
    This namespace is where "normal" global variables are stored, i.e. missionNamespace setVariable ["tst","abc"] is the same as tst="abc".
  • uiNamespace: Retains content as long as VBS is open. Switching missions or user profiles does not reset content.
  • profileNamespace: Retains content for the current user profile, even after restarting VBS.

Instead of using setVariable & getVariable, it is also possible to use with to assign or read variables:

uiNameSpace setVariable ["myString","abc"];
uiNameSpace setVariable ["myNumbers",123];

// is the same as
with uiNamespace do {
  myString= "abc";
  myNumbers = 123;
};

// and can be read via:
player sidechat (uiNameSpace getVariable "myString");
player sidechat str (uiNameSpace getVariable "myNumbers");

// or
with uiNameSpace do {
  player sidechat myString;
  player sidechat str myNumbers;
};