Added more property options to MCA

2025-08-28 19:15:31 +02:00
parent 4bf630ccc5
commit a783cfaf8c
5 changed files with 202 additions and 28 deletions

@@ -68,19 +68,6 @@ api.onDestroy(callback);
| -------- | -------- | ------------------------------------------------------------ |
| callback | ( ):void | Function that will be called when the module gets destroyed. |
### onPropertyUpdate
Register a listener for when a property updates in a scene change. The listener will also be called on initial module creation.
```javascript
api.onPropertyUpdate(propertyId, callback);
```
| Argument | Type | Description |
| ---------- | ------------------ | ----------------------------------------------- |
| propertyId | string | The property ID that the listener will receive. |
| callback | ( value:any ):void | Function that receives the new property value. |
### onUserDetailsChange
Register a listener for when the user changes their details.
@@ -177,6 +164,63 @@ api.isInEditor();
**Returns** boolean _Running in editor._
## Properties
### onReferencePropertyUpdate
Register a listener for when a reference property updates in a scene change. The listener will also be called on initial module creation and when the property is changed in the editor.
```javascript
api.onReferencePropertyUpdate(propertyId, callback);
```
| Argument | Type | Description |
| ---------- | ------------------ | ----------------------------------------------- |
| propertyId | string | The property ID that the listener will receive. |
| callback | ( value:any ):void | Function that receives the new property value. |
### getReferenceProperties
Get all module reference properties.
```javascript
api.getReferenceProperties();
```
| Argument | Type | Description |
| -------- | ------ | ------------------------------------------------------------ |
| sceneId | string | The id of the scene where you want to get the properties of. |
**Returns** { [ propertyId:string ]: [Property](./ModuleClientAPIProperty) } _All reference properties_
### getReferenceProperty
Get a module reference property.
```javascript
api.getReferenceProperty(propertyId);
```
| Argument | Type | Description |
| ---------- | ------ | ------------------------------------------------- |
| propertyId | string | The id of the reference property you want to get. |
**Returns** [Property](./ModuleClientAPIProperty) _Reference property_
### hasReferenceProperty
Check if a module reference property exists.
```javascript
api.hasReferenceProperty(propertyId);
```
| Argument | Type | Description |
| ---------- | ------ | ----------------------------------------- |
| propertyId | string | The id of the property you want to check. |
**Returns** boolean _Has reference property_
## Snapshots
### onSnapshotRestore

139
ModuleClientAPIProperty.md Normal file

@@ -0,0 +1,139 @@
# ModuleClientApi - Property
Class representing the ModuleClientApi Property.
## Functions
### getValue
Get the value of the property.
```
property.getValue();
```
**Returns** any _Value of the property_
## asString
Get the value of the property as a string.
```
property.asString();
```
**Returns** string _Value of the property_
## asNumber
Get the value of the property as a number.
```
property.asNumber();
```
**Returns** number _Value of the property_
## asBoolean
Get the value of the property as a boolean.
```
property.asBoolean();
```
**Returns** boolean _Value of the property_
## asFile
Get the value of the property as a file.
```
property.asFile();
```
**Returns** { name:string, address:string } _Value of the property_
## asGiphy
Get the value of the property as a giphy.
```
property.asGiphy();
```
**Returns** { name:string, address:string } _Value of the property_
## Parameters
### _title_
Title of the property
```typescript
property.title as string;
```
### _value_
Raw value of the property
```typescript
property.value as any;
```
### _description_
Description of the property
```typescript
property.description as string;
```
### _min_
The minimal value of the property
```typescript
property.min as number;
```
### _max_
The maximal value of the property
```typescript
property.max as number;
```
### _title_
Title of the property
```typescript
property.title as string;
```
### _step_
Step size of the property
```typescript
property.step as number;
```
### _allowedValues_
Title of the property
```typescript
property.allowedValues as { id: string; name: string };
```
### _allowedTypes_
Title of the property
```typescript
property.allowedTypes as string[];
```

@@ -104,5 +104,5 @@ The module.json file serves as the central configuration file for each module in
| conditions.server | An object with condition IDs as keys and condition data as values. These are server conditions, they can be met via the [ModuleServerAPI](./ModuleServerAPI). The object is the same as `conditions.client`. | `{ condition1: { condition }, condition2: { condition } }` |
| defaultsize.width | The default width of the module. |
| defaultsize.height | The default height of the module. |
| defaultlocation.x | <span style="color:red">**Probably deprecated soon!**</span> Default x coordinate of the module. |
| defaultlocation.y | <span style="color:red">**Probably deprecated soon!**</span> Default y coordinate of the module. |
| defaultlocation.x | <span style="color:red">**Deprecated!**</span> Default x coordinate of the module. |
| defaultlocation.y | <span style="color:red">**Deprecated!**</span> Default y coordinate of the module. |

@@ -149,16 +149,6 @@ api.getModuleID();
**Returns** string[] _List of scene IDs_
### getResolution **Deprecated**
**Deprecated** This will currently return the default channel resolution. This needs to be replaced by a function that can get a scene or display resolution
Get the default channel resolution.
```javascript
api.getResolution();
```
## Clients
### getClients
@@ -295,7 +285,7 @@ api.onReferencePropertyUpdate(propertyId, callback);
### getReferenceProperties
Get all properties of a module reference in a scene.
Get all module reference properties in a scene.
```javascript
api.getReferenceProperties(sceneId);
@@ -309,7 +299,7 @@ api.getReferenceProperties(sceneId);
### getReferenceProperty
Get a property of a module reference in a scene.
Get a module reference property in a scene.
```javascript
api.getReferenceProperty(sceneId, propertyId);
@@ -324,7 +314,7 @@ api.getReferenceProperty(sceneId, propertyId);
### hasReferenceProperty
Check if a module reference has a property.
Check if a module reference property exists in a scene.
```javascript
api.hasReferenceProperty(sceneId, propertyId);

@@ -51,6 +51,7 @@
- [Introduction](./ModuleClientAPIIntroduction)
- [ModuleClientAPI](./ModuleClientAPI)
- [User](./ModuleClientAPIUser)
- [Property](./ModuleClientAPIProperty)
- [Neighbor](./ModuleClientAPINeighbor)
- [Neighbor Results](./ModuleClientAPINeighborResults)
- [GameLib](./ModuleClientAPIGameLib)