Got a question that the wiki doesn't answer? Ask on the forum (preferred), or join us on IRC.

BeastNode

CommandHelper/Staged/API/export

From EngineHub.org Wiki
Jump to: navigation, search



Vital Info

Name export
Returns void
Usages key, value
Throws IllegalArgumentException

IndexOverflowException

Since 3.3.0
Restricted
Yes
Optimizations None

Description

Stores a value in the global storage register. An arbitrary value is stored with the given key, and can be retreived using import. If the value is already stored, it is overwritten. See import(). The reference to the value is stored, not a copy of the value, so in the case of arrays, manipulating the contents of the array will manipulate the stored value. An array may be used as a key. It is converted into a string with the array values separated by dots. export() is threadsafe.

Usages

export(key, value)

Examples (How do these work?)

Example 1

Basic usage

Given the following code:

1   @var = 2;
2   export('custom.name'@var);
3   @var2 = import('custom.name');
4   msg(@var2);


The output would be:

2

Example 2

Storage of references

Given the following code:

1   @array = array(1, 2, 3);
2   export('array'@array);
3   @array[0] = 4;
4   @array2 = import('array');
5   msg(@array2);


The output would be:

{4, 2, 3}

Example 3

Array key usage

Given the following code:

1   @key = array(custom, name);
2   export(@key'value');
3   @value = import(@key);
4   msg(@value);


The output would be:

value

Example 4

Default value usage

Given the following code:

1   export('custom.name'null);
2   @value = import('custom.name''default value');
3   msg(@value);


The output would be:

default value


See Also

import



Navigation menu