[This possibly belongs in the wiki, but there does not seem to be a relevant page for it.]
Data tables are a list of values associated with a string used to access the given value. As with standard variables there are two kinds of data table; the global data table, which is accessible from any trigger, and the local data table, which can only be accessed from within the trigger in which the values in it were stored.
In terms of basic functionality the data tables behave in much the same way as variables. The action
however there are some important differences, which allow the data table to be used with much greater flexibility.
First, when we store a value in the data table we simply assign it a string as we are saving it. There is no need to first create a blank entry, as an equivalent action to initialising a variable.
Secondly, we can perform any string manipulation we wish at the time of saving, recalling or otherwise acting on a data table entry. This allows us to simulate a number of features galaxy otherwise lacks, most notable dynamic arrays. For example consider the following trigger:
The strings here are produced as a Custom Script. Strings are entered directly within quotation marks. “+” is used to conjoin strings, the same as the “Combine Strings” function. “IntToString(<int>)” returns a string from the given integer, eg IntToString(5) == “5”. lv_<Script Identifier> is used to access a given local variable. The scrip identifier is found in the details of the variable and by default is the name of the variable with no spaces and beginning with a lower case letter, so "My First Variable" would become "myFirstVaraible". gv_<Script Identifier> and lp_<Script Identifier> are used to access global variable and parameters (for custom actions) respectively.
The condition “Data Table Value Exists” allows us to check whether we have already store a value in the pseudo-array at values of i, incrementing until we reach an unused value through a while loop.
Whilst the data tables are more flexible than standard variables, they also have to be treated with more care. In order to recall an entry in the data table the string must be exactly the same, including capitals, spaces, punctuation etc. Furthermore the value in the data table has a type associated with it, however it will not return an error if you try to implicitly change this type. For example if we have and integer n then
will set n to be 0, the default for an integer, not 5, since 5.0, a real value, is stored in the data table. You can check the type of value stored in the data table with the “Type Of Data Table Value” function.
To remove a specific data table value use the “Remove Data Table Value” action and to clear a data table use the “Clear Data Table” action.
So Data Tables are essentially used to store values as strings?
Also for the last part where you set integer n to X, since x is real n will be 0. Does that mean X can have several different values depending on its type? For example is it possible to do this.
Save Data Table Value (Real)
Value: 5.0
Name: "x"
Scope: Global
Save Data Table Value (Integer)
Value: 3
Name: "x"
Scope: Global
You can only associate one value with any given string at a time. The code you suggested would simply overwrite the value 5.0 <real> with 3 <int> and attempting to recall the real value would return 0.0.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
[This possibly belongs in the wiki, but there does not seem to be a relevant page for it.]
Data tables are a list of values associated with a string used to access the given value. As with standard variables there are two kinds of data table; the global data table, which is accessible from any trigger, and the local data table, which can only be accessed from within the trigger in which the values in it were stored.
In terms of basic functionality the data tables behave in much the same way as variables. The action
is almost exactly the same as
however there are some important differences, which allow the data table to be used with much greater flexibility.
First, when we store a value in the data table we simply assign it a string as we are saving it. There is no need to first create a blank entry, as an equivalent action to initialising a variable.
Secondly, we can perform any string manipulation we wish at the time of saving, recalling or otherwise acting on a data table entry. This allows us to simulate a number of features galaxy otherwise lacks, most notable dynamic arrays. For example consider the following trigger:
The strings here are produced as a Custom Script. Strings are entered directly within quotation marks. “+” is used to conjoin strings, the same as the “Combine Strings” function. “IntToString(<int>)” returns a string from the given integer, eg IntToString(5) == “5”. lv_<Script Identifier> is used to access a given local variable. The scrip identifier is found in the details of the variable and by default is the name of the variable with no spaces and beginning with a lower case letter, so "My First Variable" would become "myFirstVaraible". gv_<Script Identifier> and lp_<Script Identifier> are used to access global variable and parameters (for custom actions) respectively.
The condition “Data Table Value Exists” allows us to check whether we have already store a value in the pseudo-array at values of i, incrementing until we reach an unused value through a while loop.
Whilst the data tables are more flexible than standard variables, they also have to be treated with more care. In order to recall an entry in the data table the string must be exactly the same, including capitals, spaces, punctuation etc. Furthermore the value in the data table has a type associated with it, however it will not return an error if you try to implicitly change this type. For example if we have and integer n then
will set n to be 0, the default for an integer, not 5, since 5.0, a real value, is stored in the data table. You can check the type of value stored in the data table with the “Type Of Data Table Value” function.
To remove a specific data table value use the “Remove Data Table Value” action and to clear a data table use the “Clear Data Table” action.
So Data Tables are essentially used to store values as strings?
Also for the last part where you set integer n to X, since x is real n will be 0. Does that mean X can have several different values depending on its type? For example is it possible to do this.
Save Data Table Value (Real)
Value: 5.0
Name: "x"
Scope: Global
Save Data Table Value (Integer)
Value: 3
Name: "x"
Scope: Global
Will that work?
Local is thread local, so not entirely correct.
@gizmachu: Go
You can only associate one value with any given string at a time. The code you suggested would simply overwrite the value 5.0 <real> with 3 <int> and attempting to recall the real value would return 0.0.