To simplify the creation of devices for Obsidian, we are releasing a set of Express API scripts that handle the complexity of the standard API for you. The package will be expanded over time to cover more use cases. The scripts hide the complexity of the full API and provide a simpler interface for common tasks.

Express API Scripts are denoted by the { and } in their names, for example */ aeros / API {Wearable:React+Constrain}.

If you are using an Express API script, do not add the standard API script */ aeros / API in your item. If you need more control than what the Express API provides, rewrite your code to use only the standard API.

Wearable:React+Constrain

Name of the script: */ aeros / API {Wearable:React+Constrain}

Changelog

  • v109.2
    • Add OBS_requestState() wrapper function to request current state from Obsidian.
  • v109.1
    • Fixed a bug in {Wearable:React+Constrain} where the script did not properly notify fluids events until fluid type changes.
    • Add more flags related to fluids and throbbing.
  • v109 - Initial release of Express API script (starting with just one, {Wearable:React+Constrain}).

Purpose

This Express API script provides an interface to:

  1. React to Obsidian’s initial state and to changes made by the user (or by other scripts on behalf of a user), and
  2. Constrain Obsidian. The Express API script handles periodic enforcement for you.

It is intended for wearable items that need to react to Obsidian’s changed state — for example, to hide or show the item they control based on Obsidian’s visibility, or to enforce specific rules about Obsidian’s behavior. This Express API script only works for attachments with the same owner.

Behind the scenes, the script subscribes to Obsidian’s notification system and processes changes in a way that is easy to use in a script. It ensures notifications are only sent when the changes really happen (after initial notification). Obsidian’s state is saved in LSD1 memory for easy access from any scripts in the same linkset.

Setup

  1. Drop the */ aeros / API {Wearable:React+Constrain} script into the item you are developing. Change permissions as you like.
  2. Create another script that will respond to changes in Obsidian and optionally set constraints using the API script you added. Change its permissions according to your needs.
    • Start with the Template script
      • Or check out other scripts in the Examples section.
    • Adapt the script to your needs.
      • You can ask an AI assistant to help you. We’ve included comments to help you and the AI understand how it works, as well as links to LSL documentation and Aeros API for reference.

Footnotes

  1. LSD — abbreviation for Linkset Data.