mooball
    Preparing search index...

    Interface Addon

    interface Addon {
        defineMetadata(metadata?: any): void;
        defineVariable(variable: Variable): any;
        finalize(): void;
        initialize(): void;
        room: IRoom;
        setVariableGUIProps(
            varName: string,
            ...vals: { name: string; value: any }[],
        ): void;
    }
    Index

    Properties

    room: IRoom

    The room that this Addon is currently attached to.

    Methods

    • This function is called internally inside the constructor of all Addons by default. The function body is empty by default. This means that the metadata values are not stored in Addon objects by default, because they are not useful in a non-GUI node.js environment. If we want to make use of the metadata, we might override this behavior by overriding this method. Remember that this should be done after initializing the API and before initializing any Addons.

      Parameters

      • Optionalmetadata: any

        An object that holds some metadata values. This value might depend on what you want to do with this API. The examples in the GitHub repo are intended to be shown in a web application GUI that can be accessed by anyone. Therefore, they use the following structure for this object:

        • name: string: Name of the RoomConfig that will be displayed on the GUI.
        • version: number: The current version number of this RoomConfig.
        • author: string: The author of this RoomConfig.
        • description: string: A detailed description of this RoomConfig.
        • allowFlags: int: This value defines whether it is possible to use this Addon while hosting or joining (or both) a room. Renderers do not use this key.

      Returns void

      void.

      // To prevent unnecessary memory usage
      RoomConfig.prototype.defineMetadata = function(metadata){};
      // In a complex website, whenever metadata is needed
      RoomConfig.prototype.defineMetadata = function(metadata){
      this.metadata = metadata;
      };
    • This function defines a variable inside the Addon object that can be changed from outside. If we want to make use of the metadata that we sent into this function, we can override this function. Only name and value fields are used by the default implementation. The implementation also depends on the API's global config.noVariableValueChangeEvent variable, since this function will also fire an onVariableValueChange event whenever a variable's value changes if this value is not true.

      Parameters

      • variable: Variable

        An object that might hold some metadata values along with the variable's name and value. This object might depend on what you want to do with this API. The examples in the GitHub repo are intended to be shown in a web application GUI that can be accessed by anyone. Therefore, this metadata structure has fields such as type, description and range.

      Returns any

      // In a complex website, whenever variable metadata is needed:
      RoomConfig.prototype.defineMetadata = function(metadata){
      //...do other stuff...
      this.variables = {}; // define an object that will hold all variable details inside all RoomConfigs.
      };
      var originalDefineVariable = RoomConfig.prototype.defineVariable;
      RoomConfig.prototype.defineVariable = function(variable){
      //...do other stuff...
      originalDefineVariable(variable);
      this.variables[variable.name] = { // store all variable details inside all RoomConfigs, so that you can show them later in your GUI application if you want to.
      type: variable.type,
      range: variable.range,
      description: variable.description
      };
      //...do other stuff...
      };
    • If defined, called while leaving a room, or during a call to Room.updateLibrary, Room.removeLibrary, Room.updatePlugin, Room.removePlugin, Room.setConfig or Room.setRenderer. We should write all custom finalization logic inside this callback function.

      Returns void

      void.

    • If defined, called while creating or joining a room, or during a call to Room.addLibrary, Room.updateLibrary, Room.addPlugin, Room.updatePlugin, Room.setConfig or Room.setRenderer. You should write all custom initialization logic inside this callback function.

      Returns void

      void.

    • This function might be used to modify some GUI properties regarding a specific variable called varName. The function body is empty by default, since we do not have a GUI in a non-GUI node.js environment. All other parameters after the first parameter should be structured as {name: propName, value: propValue}. Here, each property named propName is requested to set its new value to propValue. For example; in a GUI environment, setVariableGUIProps("testVariable", {name: "visible", value: false}) could make the testVariable disappear from the GUI.

      Parameters

      • varName: string

        The name of the variable whose GUI properties are desired to be modified.

      • ...vals: { name: string; value: any }[]

        The property name/value pairs.

      Returns void

      void.