Constructor
new ScriptAttributes(scriptType)
Parameters:
Name | Type | Description |
---|---|---|
scriptType |
ScriptType | Script Type that attributes relate to. |
- Source:
Methods
add(name, args)
Add Attribute
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
name |
String | Name of an attribute | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
args |
Object | Object with Arguments for an attribute
Properties
|
- Source:
Examples
PlayerController.attributes.add('fullName', {
type: 'string',
});
PlayerController.attributes.add('speed', {
type: 'number',
title: 'Speed',
placeholder: 'km/h',
default: 22.2
});
PlayerController.attributes.add('resolution', {
type: 'number',
default: 32,
enum: [
{ '32x32': 32 },
{ '64x64': 64 },
{ '128x128': 128 }
]
});
get(name) → {Object}
Get object with attribute arguments.
Note: Changing argument properties will not affect existing Script Instances.
Parameters:
Name | Type | Description |
---|---|---|
name |
String | Name of an attribute |
- Source:
Returns:
Arguments with attribute properties
- Type
- Object
Example
// changing default value for an attribute 'fullName'
var attr = PlayerController.attributes.get('fullName');
if (attr) attr.default = 'Unknown';
has(name) → {Boolean}
Detect if Attribute is added.
Parameters:
Name | Type | Description |
---|---|---|
name |
String | Name of an attribute |
- Source:
Returns:
True if Attribute is defined
- Type
- Boolean
Example
if (PlayerController.attributes.has('fullName')) {
// attribute `fullName` is defined
});
remove(name) → {Boolean}
Remove Attribute.
Parameters:
Name | Type | Description |
---|---|---|
name |
String | Name of an attribute |
- Source:
Returns:
True if removed or false if not defined
- Type
- Boolean
Example
PlayerController.attributes.remove('fullName');