VariableStore Class
A storage for different kind of game variables. The following scopes for variables exist:
- Local Variables -> Only valid for the current scene.
- Global Variables -> Valid for the whole game but bound to a single save-game.
- Persistent Variables -> Valid for the whole game indepentent from the save-games.
The following data-types exist:
- Strings -> Variables storing text data. - Numbers -> Variables storing integer number values. - Booleans -> Variables storing boolean values. (Called "Switches" for easier understanding) - Lists -> Variables storing multiple other variables. Lists can also contain Lists.Local variables are stored by scene UID. For each scene UID a list of local variables is stored.
Global and persistent variables are stored and a specific domain. A domain is just a unique name such as com.example.game for example. The default domain is an empty string. Domains are useful to avoid overlapping of variable numbers when sharing content with other users.
Item Index
Methods
- booleanValueAtIndex
- booleanValueOf
- changeDomain
- clearAllLocalVariables
- clearGlobalVariables
- clearGlobalVariables
- clearLocalVariables
- clearPersistentVariables
- clearVariables
- listObjectOf
- numberValueAtIndex
- numberValueOf
- onDataBundleRestore.
- setBooleanValueAtIndex
- setBooleanValueTo
- setListObjectTo
- setNumberValueAtIndex
- setNumberValueAtIndex
- setStringValueAtIndex
- setStringValueTo
- setup
- setupLocalVariables
- setupTempVariables
- setupVariables
- stringValueAtIndex
- stringValueOf
Methods
booleanValueAtIndex
-
scope -
index
Gets the value of a boolean variable at the specified index.
Parameters:
-
scopeNumber- The variable scope.
-
indexNumber- The variable's index.
Returns:
The boolean value of the variable.
booleanValueOf
-
object
Gets the value of a specified boolean variable.
Parameters:
-
objectObject- The variable to get the value from.
Returns:
The boolean value of the variable.
changeDomain
-
domain
Changes the current domain.
Parameters:
-
domainString- The domain to change to.
clearAllLocalVariables
()
Clears all local variables for all contexts/scenes/common-events.
clearGlobalVariables
-
type -
range
Clears global variables.
Parameters:
-
typeNumber- Determines what kind of variables should be cleared.
- 0 = All
- 1 = Switches / Booleans
- 2 = Numbers
- 3 = Texts
- 4 = Lists
-
rangeObject- The variable id-range to clear. If null all variables are cleared.
clearGlobalVariables
()
Clears all global variables
clearLocalVariables
-
context -
type -
range
Clears all local variables for a specified context. If the context is not specified, all local variables for all contexts/scenes/common-events are cleared.
Parameters:
-
contextObject- The context to clear the local variables for. If null, all
-
typeNumber- Determines what kind of variables should be cleared.
- 0 = All
- 1 = Switches / Booleans
- 2 = Numbers
- 3 = Texts
- 4 = Lists
-
rangeObject- The variable id-range to clear. If null all variables are cleared.
clearPersistentVariables
-
type -
range
Clears persistent variables.
Parameters:
-
typeNumber- Determines what kind of variables should be cleared.
- 0 = All
- 1 = Switches / Booleans
- 2 = Numbers
- 3 = Texts
- 4 = Lists
-
rangeObject- The variable id-range to clear. If null all variables are cleared.
clearVariables
-
numbers -
strings -
booleans -
lists -
type -
range
Clears specified variables.
Parameters:
-
numbersNumber- The number variables to clear.
-
stringsString- The string variables to clear.
-
booleansBoolean- The boolean variables to clear.
-
listsArray- The list variables to clear.
-
typeNumber- Determines what kind of variables should be cleared.
- 0 = All
- 1 = Switches / Booleans
- 2 = Numbers
- 3 = Texts
- 4 = Lists
-
rangeObject- The variable id-range to clear. If null all specified variables are cleared.
listObjectOf
-
object
Gets the value of a specified list variable.
Parameters:
-
objectObject- The list-variable/object to get the value from.
Returns:
The list-object.
numberValueAtIndex
-
scope -
index
Gets the value of a number variable at the specified index.
Parameters:
-
scopeNumber- The variable scope.
-
indexNumber- The variable's index.
Returns:
The number value of the variable.
numberValueOf
-
object
Gets the value of a specified number variable.
Parameters:
-
objectObject- The variable to get the value from.
Returns:
The number value of the variable.
onDataBundleRestore.
-
Object -
gs.ObjectCodecContext
Called if this object instance is restored from a data-bundle. It can be used re-assign event-handler, anonymous functions, etc.
Parameters:
-
ObjectObjectdata - The data-bundle
-
gs.ObjectCodecContextObjectcontext - The codec-context.
setBooleanValueAtIndex
-
scope -
index -
value
Sets the value of the boolean variable at the specified index.
Parameters:
-
scopeNumber- The variable scope.
-
indexNumber- The variable's index.
-
valueBoolean- The value to set.
setBooleanValueTo
-
variable -
value
Sets the value of a specified boolean variable.
Parameters:
-
variableObject- The variable to set.
-
valueBoolean- The value to set.
setListObjectTo
-
variable -
value
Sets the value of a specified list variable.
Parameters:
-
variableObject- The variable to set.
-
valueObject- The value to set.
setNumberValueAtIndex
-
scope -
index -
value
Sets the value of the number variable at the specified index.
Parameters:
-
scopeNumber- The variable scope.
-
indexNumber- The variable's index.
-
valueNumber- The value to set.
setNumberValueAtIndex
-
variable -
value
Sets the value of a specified number variable.
Parameters:
-
variableNumber- The variable to set.
-
valueNumber- The value to set.
setStringValueAtIndex
-
scope -
index -
value
Sets the value of the string variable at the specified index.
Parameters:
-
scopeNumber- The variable scope.
-
indexNumber- The variable's index.
-
valueString- The value to set.
setStringValueTo
-
variable -
value
Sets the value of a specified string variable.
Parameters:
-
variableObject- The variable to set.
-
valueString- The value to set.
setup
-
context
Initializes the variables. Should be called whenever the context changes. (Like after a scene change)
Parameters:
-
contextObject- The context(current scene) needed for local variables. Needs have at least an id-property.
setupLocalVariables
-
context
Initializes the local variables for the specified context. Should be called on first time use.
Parameters:
-
contextObject- The context(current scene). Needs have at least an id-property.
setupTempVariables
-
context
Initializes the current temp variables for the specified context. Should be called whenever the context changed.
Parameters:
-
contextObject- The context(current scene). Needs have at least an id-property.
setupVariables
-
context -
property -
defaultValue
Initializes the specified kind of variables.
Parameters:
-
contextObject- The context(current scene). Needs have at least an id-property.
-
propertyString- The kind of variables (property-name).
-
defaultValueObject- The default value for each variable.
stringValueAtIndex
-
scope -
index
Gets the value of a string variable at the specified index.
Parameters:
-
scopeNumber- The variable scope.
-
indexNumber- The variable's index.
Returns:
The string value of the variable.
stringValueOf
-
object
Gets the value of a specified string variable.
Parameters:
-
objectObject- The variable to get the value from.
Returns:
The string value of the variable.
Properties
booleans
Boolean
The global boolean variables of the current domain.
context
Object
Current local variable context
domain
Object
Current domain for global and persistent variables. Each domain has its own variables. Please use changeDomain method to change the domain.
domains
String
List of available domains for global and persistent variables.
globalVariablesByDomain
Object[]
The storage of all global variables by domain.
lists
Object[]
The global list variables of the current domain.
localBooleans
Number
localBooleans
Object
The local boolean variables.
localLists
Object[]
localLists
Object
The local list variables.
localNumbers
Object
The local number variables.
localStrings
Object
The local string variables.
numbers
Number
The global number variables of the current domain.
persistentBooleans
Boolean
The persistent boolean variables of the current domain.
persistentLists
Object[]
The persistent list variables of the current domain.
persistentNumbers
Number
The persistent number variables of the current domain.
persistentStrings
String
The persistent string variables of the current domain.
persistentVariablesByDomain
Object[]
The storage of all persistent variables by domain.
strings
String
The global string variables of the current domain.
