[WIP] set global variable: name = <Var/String> value = <Value>

This forum serves as MSCI Reference at EGOSOFT. It's Read-Only for non MSCI Group members.

Moderators: Scripting / Modding Moderators, MSCI Moderators

Post Reply
mark_a_condren
Posts: 1385
Joined: Wed, 3. Aug 05, 05:05
x3tc

[WIP] set global variable: name = <Var/String> value = <Value>

Post by mark_a_condren » Thu, 9. Sep 10, 10:31

set global variable: name = <Var/String> value = <Value>


<Var/String> = The string to set as the name for the information, this can be read in from a text file or entered directly as a string. For a global variable it is Vital to make every effort to ensure the name is Unique to this global variable only to avoid conflicts.
<Value> = The information being stored.



This instruction takes any script variable that is running, and stores its value.
The term “global variable” is probably unfortunate – the concept is more akin to storing a file on a hard drive.
Think of <Var/String> as the file name, and <Value> as the data in the file.
Any variable type can be stored in this way, including an entire array.

The difference between a global variable and a local variable, as the set local and set global instructions use the terms, is whether or not the value is stored locally on a particular ship or base, or stored globally.
To continue the file analogy, the set local variable instruction is like storing a file in a directory, where each and every ship and station has its own directory.
The set global variable instruction is like storing the file in the root directory – any script running on any ship or base can access or change the value when it is stored as a global variable.


Example:

set global variable: name = 'my_global_variable_name' value = $info.to.be.stored

Further Resources:
Global Variables by Cycrow.


Command Location:

Post Reply

Return to “MSCI Reference”