CustomPropertyAccessor¶
CustomPropertyAccessor
is a struct for accessing custom properties.
Note: You may want to cache the accessor for later usage in your script.
However, if the cached custom property (or its parent property) is removed, the accessor will be unusable.Functions¶
CustomPropertyType GetCustomPropertyType()¶
ReturnsCustomPropertyType.Null if the entity is not valid or no custom property is configured
Gets the CustomPropertyType
for the current entity.
boolean IsNull()¶
Returnstrue if this custom property is accessible.
Verifies whether this custom property is accessible.
Use this function to check the item returned by a map or list.
number Count()¶
Returns0 if the custom property is neither list nor map.
Gets the item count stored on the current custom property.
Array<string> GetAllKeys()¶
Returnsa list of keys
Gets a list of strings that represent the keys for the current custom property if it's a map.
CustomPropertyAccessor GetItem(string key)¶
ReturnsThe accessor for the specified key
Only available when the custom property is a map.
Returns an accessor for the specified key.
If the index does not exist, returns an accessor with CustomPropertyType
being CustomPropertyType.Null
.
key
The targeted string key
CustomPropertyAccessor GetItem(number index)¶
ReturnsThe accessor for the specified index
Only available when the custom property is a list.
Returns an accessor for the specified index.
If the key does not exist, returns an accessor with CustomPropertyType
being CustomPropertyType.Null
.
index
The targeted index
CustomPropertyAccessor GetHead()¶
ReturnsThe accessor for the first element in the list
Only available when the custom property is a list.
Returns the accessor for the first element in the list.
If the list is empty, returns an accessor with CustomPropertyType
being CustomPropertyType.Null
.
CustomPropertyAccessor GetTail()¶
Returnsthe accessor for the last element in the list
Only available when the custom property is a list.
Returns the accessor for the last element in the list.
If the list is empty, returns an accessor with CustomPropertyType
being CustomPropertyType.Null
.
number GetNumber()¶
Returns0 if the custom property is not of type CustomPropertyType.Number
Gets the Number value from the custom property.
boolean GetBoolean()¶
Returnsfalse if the custom property is not of type CustomPropertyType.Boolean
Gets the Boolean value from the custom property.
string GetString()¶
Returnsnull if the custom property is not of type CustomPropertyType.String
Gets the String value from the custom property.
boolean AddOrUpdateNumber(string key, number value)¶
SERVER ONLY
Returnstrue if a new custom property is created
Only for a map.
Finds the custom property with the specified key and updates it with the Number value.
If the map does not contain an entry with the key, a new custom property is created.
key
The string key to add or update in the mapvalue
The number value to add or update
boolean AddOrUpdateBoolean(string key, boolean value)¶
SERVER ONLY
Returnstrue if a new custom property is created.
Only for a map.
Finds the custom property with the specified key and updates it with the Boolean value.
If the map does not contain an entry with the key, a new custom property is created.
key
The String key to add or update in the mapvalue
The Boolean value to add or update
boolean AddOrUpdateString(string key, string value)¶
SERVER ONLY
Returnstrue if a new custom property is created
Only for a map.
Finds the custom property with the specified key and updates it with the String value.
If the map does not contain an entry with the key, a new custom property is created.
key
The String key to add or update in the mapvalue
The string value to add or update
CustomPropertyAccessor AddOrUpdateMap(string key)¶
SERVER ONLY
Returnsthe CustomPropertyAccessor for the added map.
Only for a map.
Finds the custom property with the specified key and updates it with an empty map.
If the map does not contain an entry with the key, a new custom property is created.
key
The String key to add or update in the map
CustomPropertyAccessor AddOrUpdateList(string key)¶
SERVER ONLY
Returnsthe CustomPropertyAccessor for the added list.
Only for a map.
Finds the custom property with the specified key and updates it with an empty list.
If the map does not contain an entry with the key, a new custom property is created.
key
The String key to add or update in the map
boolean Remove(string key)¶
SERVER ONLY
Returnstrue if a custom property was removed
Only for a map.
Removes the custom property for the specified key.
key
The string key to remove from the map
void AppendNumber(number value)¶
SERVER ONLY
Only for a list.
Appends the Number value to the end of the list.
value
The Number value to append
void AppendBoolean(boolean value)¶
SERVER ONLY
Only for a list.
Appends the Boolean value to the end of the list.
value
The Boolean value to append
void AppendString(string value)¶
SERVER ONLY
Only for a list.
Appends the String value to the end of the list.
value
The String value to append
CustomPropertyAccessor AppendList()¶
SERVER ONLY
ReturnsThe property accessor for the new property
Only for a list.
Appends an empty list to the end of the list.
CustomPropertyAccessor AppendMap()¶
SERVER ONLY
ReturnsThe property accessor for the new property
Only for a list.
Appends an empty map to the end of the list.
void PrependNumber(number value)¶
SERVER ONLY
Only for a list.
Inserts the Number value at the start of the list.
value
The Number value to prepend
void PrependBoolean(boolean value)¶
SERVER ONLY
Only for a list.
Inserts the Boolean value at the start of the list.
value
The Boolean value to prepend
void PrependString(string value)¶
SERVER ONLY
Only for a list.
Inserts the String value at the start of the list.
value
The String value to prepend
CustomPropertyAccessor PrependList()¶
SERVER ONLY
ReturnsThe property accessor for the new property
Only for a list.
Inserts an empty list at the start of the list.
CustomPropertyAccessor PrependMap()¶
SERVER ONLY
ReturnsThe property accessor for the new property
Only for a list.
Inserts an empty map at the start of the list.
boolean SetNumberAt(number index, number value)¶
SERVER ONLY
Returnsfalse if the setting fails for a reason, such as the index is out of range.
Only for a list.
Sets the value at the specified index of the list.
index
The index where to set the valuevalue
The Number value to set
boolean SetBooleanAt(number index, boolean value)¶
SERVER ONLY
Returnsfalse if the setting fails for a reason, such as the index is out of range.
Only for a list.
Sets the value at the specified index of the list.
index
The index where to set the valuevalue
The Boolean value to set
boolean SetStringAt(number index, string value)¶
SERVER ONLY
Returnsfalse if the setting fails for a reason, such as the index is out of range.
Only for a list.
Sets the value at the specified index of the list.
index
The index where to set the valuevalue
The String value to set
CustomPropertyAccessor SetMapAt(number index)¶
SERVER ONLY
Returnsthe CustomPropertyAccessor for the new map. The accessor will be null if the setting fails for a reason, such as the index is out of range.
Only for a list.
Sets an empty map at the specified index of the list.
index
The index where to set the map
CustomPropertyAccessor SetListAt(number index)¶
SERVER ONLY
Returnsthe CustomPropertyAccessor for the new list. The accessor will be null if the setting fails for a reason, such as the index is out of range.
Only for a list.
Sets an empty list at the specified index of the list.
index
The index where to set the map
number Clip(number startIndex, number expectedCount)¶
SERVER ONLY
Returnsthe resulted count of the elements in the list. The count may be smaller than expectedCount when the list is too short. Returns -1 if the clipping fails for a reason, such as the custom property is not a list.
Only for a list.
Clips the values in a list to the specified range, starting from startIndex
.
The value count is expectedCount.
startIndex
The start index for the clipping. It must not be smaller than 0.expectedCount
The number of values. The expected count must not be smaller than 0.
void Clear()¶
SERVER ONLY
Only applicable to map or list.
Clears up the container.