CasualOS Documentation
website·Indexed 31 days ago
https://docs.casualos.com/Technical documentation for the CasualOS platform, covering scripting, AUX code, and system APIs. Includes detailed type definitions for OS services (camera, geolocation, clipboard, media), record management (databases, files, events), AI capabilities (chat, image generation), and bot behavior via listen tags.
What's inside CasualOS
- CasualOS is a free, open-source platform maintained by the non-profit Casual Simulation. It is designed to simplify the authoring and sharing of AUXes. In the CasualOS ecosystem, the computers running the software are referred to as 'servers', which are used to host 'instances'.
Overview of CasualOS
CasualOS is a free, open-source platform designed to facilitate the authoring and sharing of AUXes. It is maintained by the non-profit organization Casual Simulation. The software is distributed under the MIT License, allowing it to be copied and reused freely.Overview of Vector2 in CasualOS
TheVector2class represents 2D positions and directions in CasualOS. It is used to handle X and Y coordinates and perform common mathematical operations. When saved to tags, these are stored as vector tags.Overview of the gridPortal
ThegridPortalis a specific type of portal in CasualOS that renders bots as 3D cubes positioned on an infinite grid of squares.Overview of CasualOS
CasualOS is a tool designed for problem-solving and testing solutions through the use of automation. It provides a framework for creating experiences that leverage automated processes, supported by a conceptual learning series called "The Pillars of Casual Simulation" which introduces core computing and automation concepts used within the platform.Use the RoomTrackOptions interface for audio/video track properties
TheRoomTrackOptionsinterface defines the properties of an audio or video track in a room. It includes metadata about the track's source, its remote status, and video-specific attributes like aspect ratio and dimensions.interface RoomTrackOptions { aspectRatio?: number; // The aspect ratio of the video (if applicable) dimensions?: object; // The dimensions of the video (if applicable) isRemote: boolean; // True if the track is sourced from a remote user kind: TrackKind; // The type of the track muted: boolean; // Whether the track is muted locally remoteId: string; // The ID of the remote user publishing this track source: TrackSource; // The source of the track videoQuality?: TrackVideoQuality; // The video quality (if applicable) }Use the Quaternion class for 3D transformations
The
Quaternionclass represents 3D rotations and transformations using the formulaq = w + xi + yj + zk. In this representation,x,y, andzdefine the rotation axis vector, andwdefines the rotation angle. Quaternions are preferred over Euler angles to avoid gimbal lock.Note that quaternions can also represent scale and reflection based on how they are applied to a point:
- Rotation and Scale:
quaternion * point * inverse(quaternion). The point is rotated around the axis and scaled by the quaternion's length. - Reflection and Scale:
quaternion * point * quaternion. The point is reflected across the axis and scaled by the quaternion's length.
To represent only rotation without scaling, the quaternion must be normalized (length = 1).
- Rotation and Scale:
Understand and use Tags in CasualOS
Tags in CasualOS are name-value pairs associated with a bot, representing specific attributes. They serve two primary purposes: storing data and triggering automations that respond to user actions.
CasualOS includes 'built-in tags' which provide predefined automations to control bot behavior or appearance. For example:
#color: Changes the display color of a bot.#label: Displays a text label on a bot.
Listen for debugger pauses using onPause
TheonPausemethod registers a handler function that is triggered whenever the debugger is paused by a pause trigger. The handler receives aDebuggerPauseobject containing details about the pause.const debug = await os.createDebugger({ pausable: true }); debug.onPause(pause => { console.log('pause happened!', pause); });Monitor remote user status with RoomRemoteOptions
TheRoomRemoteOptionsinterface provides information about a remote user's streaming status and connection quality.interface RoomRemoteOptions { audio: boolean; audioLevel: number; // Range 0 to 1 connectionQuality: "unknown" | "excellent" | "good" | "poor" | "lost"; screen: boolean; video: boolean; }Understand CasualOS Instances
An instance (also referred to as an 'inst') is a shared simulation of bots that is hosted on a CasualOS Server.Use the sheetPortal to manage bots in a dimension
ThesheetPortalis a portal interface that allows developers to view and edit bots located within a specific dimension. It organizes bots in a spreadsheet-like layout where each bot is represented as a column and each tag is represented as a row.