From a783cfaf8c957c622f755bbe2d01c7f82e84e042 Mon Sep 17 00:00:00 2001 From: Mees van der Wijk Date: Thu, 28 Aug 2025 19:15:31 +0200 Subject: [PATCH] Added more property options to MCA --- ModuleClientAPI.md | 70 +++++++++++++++---- ModuleClientAPIProperty.md | 139 +++++++++++++++++++++++++++++++++++++ ModuleJSON.md | 4 +- ModuleServerAPI.md | 16 +---- _Sidebar.md | 1 + 5 files changed, 202 insertions(+), 28 deletions(-) create mode 100644 ModuleClientAPIProperty.md diff --git a/ModuleClientAPI.md b/ModuleClientAPI.md index f5bc6bd..2fd3014 100644 --- a/ModuleClientAPI.md +++ b/ModuleClientAPI.md @@ -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 diff --git a/ModuleClientAPIProperty.md b/ModuleClientAPIProperty.md new file mode 100644 index 0000000..9b7a98c --- /dev/null +++ b/ModuleClientAPIProperty.md @@ -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[]; +``` diff --git a/ModuleJSON.md b/ModuleJSON.md index 7c0ca77..9dea88c 100644 --- a/ModuleJSON.md +++ b/ModuleJSON.md @@ -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 | **Probably deprecated soon!** Default x coordinate of the module. | -| defaultlocation.y | **Probably deprecated soon!** Default y coordinate of the module. | +| defaultlocation.x | **Deprecated!** Default x coordinate of the module. | +| defaultlocation.y | **Deprecated!** Default y coordinate of the module. | diff --git a/ModuleServerAPI.md b/ModuleServerAPI.md index f705fdb..69f8303 100644 --- a/ModuleServerAPI.md +++ b/ModuleServerAPI.md @@ -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); diff --git a/_Sidebar.md b/_Sidebar.md index 4d8c784..ee5e361 100644 --- a/_Sidebar.md +++ b/_Sidebar.md @@ -51,6 +51,7 @@ - [Introduction](./ModuleClientAPIIntroduction) - [ModuleClientAPI](./ModuleClientAPI) - [User](./ModuleClientAPIUser) + - [Property](./ModuleClientAPIProperty) - [Neighbor](./ModuleClientAPINeighbor) - [Neighbor Results](./ModuleClientAPINeighborResults) - [GameLib](./ModuleClientAPIGameLib)