VariablesContainer

VariablesContainer

VariablesContainer stores variables, usually for a a RuntimeGame, a RuntimeScene or a RuntimeObject.

Constructor

new VariablesContainer(initialVariablesDataopt)

Parameters:
Name Type Attributes Description
initialVariablesData <optional>

Optional array containing representations of the base variables.

Source:

Methods

add(name, newVariable)

Add a new variable. This can be costly, don't use in performance sensitive paths.

Parameters:
Name Type Description
name

Variable name

newVariable

The variable to be added

Source:

get(name)

Get a variable.

Parameters:
Name Type Description
name

The variable's name

Returns:
Type Description

The specified variable. If not found, an empty variable is added to the container.

Source:

getFromIndex(id)

Get a variable using its index. If you're unsure about how to use this method, prefer to use get. The index of a variable is its index in the data passed to initFrom.

This method is generally used by events generated code to increase lookup speed for variables.

Parameters:
Name Type Description
id

The variable index

Returns:
Type Description

The specified variable. If not found, an empty variable is added to the container, but it should not happen.

Source:

has(name)

Check if a variable exists in the container.

Parameters:
Name Type Description
name

The variable's name

Returns:
Type Description

true if the variable exists.

Source:

initFrom(data, keepOldVariablesopt)

Initialize variables from a container data.
If keepOldVariables is set to false (by default), all already existing variables will be erased, but the new variables will be accessible thanks to getFromIndex.
if keepOldVariables is set to true, already existing variables won't be erased and will be still accessible thanks to getFromIndex.

Parameters:
Name Type Attributes Description
data

The array containing data used to initialize variables.

keepOldVariables <optional>

If set to true, already existing variables won't be erased.

Source:

remove(name)

Remove a variable. (the variable is not really removed from the container to avoid creating garbage, but marked as undefined)

Parameters:
Name Type Description
name

Variable to be removed

Source: