GSQItem Class
Describes all general properties each GSQ item can have. A GSQ item is used to describe a single field of a scene command like a character-selection, duration value, a popup-list, etc.
Item Index
Properties
attribute
String
The path of the backend-field where the item should store its data. For Example:
myField
Stores the data in params.myField of the command object. It is also possible to specify paths like:
myField.mySubField
In the above example the data is written into params.myField.mySubField of the command object. If myField doesn't exist it will be automatically created an initialized with an empty object. It is also possible to specify paths to array values like:
myField.mySubArray.4
In the above example the data is written into params.myField.mySubArray[4]. If the array or the index doesn't exist it it automatically created. In our example, the values from index 0 to 3 are initializes with null
identifier
String
The unique identifier of the item. It can be any kind of text as long as it is unique inside the command. So you don’t need to follow any kind of format or syntax. If identifier is not present, the attribute is automatically used as identifier. The identifier can be used refer to the item like in enableItems or showItems property.
label
String
The field's label text to display a short description of the field.
lockable
Boolean
Indicates if the field is lockable and displays a lock-icon on the left side. If true the params-object contains a special property fieldFlags which contains flags for each property. If the field is locked, the flag 0x01 is set. For Example:
locked = params.fieldFlags["myField"] & 0x01
The above example checks if myField is locked. In game script there is a constant which can be used instead of 0x01:
locked = params.fieldFlags["myField"] & gs.CommandFieldFlags.LOCKED
Or the helper method:
locked = gs.CommandFieldFlags.isLocked(params.fieldFlags["myField"])
A field which is locked is ignored by the command and the default value is used. But the exact behavior depends on the command's implementation in gs.Component_CommandInterpreter class.
tooltip
String
Displays a popup help-text if the mouse-pointer is place above the field for a few seconds. The exact behavior of the help-text popup depends on the operating system.
type
String
The type of items like if its a number field, a text field, etc. The following types are supported:
- GSQStepper
- GSQTextArea
- GSQPopupField
- GSQDataRecordField
- GSQCheckBox
- GSQSlider
valueFormula
String
Defines a JavaScript formula calculating the display text of the fields value. The local variable "p" is a reference to the params-object. If the formula doesn't return a string the toString method is executed on the return-value. For Example:
"valueFormula": "return p.myValue"
valueTranslator
Object
A value-translator can be used to convert the item's value before written or after read. It has the following format:
valueTranslator: { read: "return ROUND(v * 100)", write: "return v / 100" }
- read - A formula is used to convert the value after read but before transferring it to the item. It has one parameter "v" which is the original value.
- write - A formula is used to convert the value before it is written to the backend. It has one parameter "v" which is the original value.
In the above example the value is stored as a factor between 0.0 and 1.0 but displayed as a percentage between 0 and 100.
variableButton
Object
Indicates if the field can be calculated by variable. Only available for GSQStepper, GSQTextArea, GSQPopupField and GSQDataRecordField. The object has the format:
"variableButton": { "dataSource": "numbers "}
The dataSource describes the variable type and can be "numbers", "strings", "booleans" or "lists".
width
Number | String
The field's width in pixels or percentage. Can be:
- "50%" - Percentage value
- 50 - Number value describing the width in pixels
- "auto" - The width is calculated automatically
Default: "auto"