### GET /api/objects/byTemplateId/{templateId} Source: https://github.com/plasticity-studios/tabletop-playground-api/blob/master/docs/classes/_api_.gameworld.html Retrieves all game objects matching a specific template ID. ```APIDOC ## GET /api/objects/byTemplateId/{templateId} ### Description Retrieves all game objects matching a specific template ID. ### Method GET ### Endpoint /api/objects/byTemplateId/{templateId} ### Parameters #### Path Parameters - **templateId** (string) - Required - The template ID to filter objects by. #### Query Parameters None #### Request Body None ### Response #### Success Response (200) - **GameObject** (array) - An array of game objects matching the specified template. #### Response Example ```json [ { "id": "obj-d6-1", "name": "Dice", "templateId": "d6", "position": {"x": 1, "y": 2, "z": 3} }, { "id": "obj-d6-2", "name": "Dice", "templateId": "d6", "position": {"x": 4, "y": 5, "z": 6} } ] ``` ``` -------------------------------- ### UIElement Class Documentation Source: https://github.com/plasticity-studios/tabletop-playground-api/blob/master/docs/classes/_api_.uielement.html Provides details on the properties and methods available for the UIElement class. ```APIDOC ## Class UIElement Represents a UI element in the game world. Can be attached to an object using `GameObject.addUI` or directly added to the world with `GameWorld.addUI`. Updates to UI element properties require calling `GameObject.updateUI` or `GameWorld.updateUI` afterwards, except for properties of the attached widget. ### Properties * **anchorX** (number) - The horizontal anchor point of the UI (0: left, 0.5: center, 1.0: right). Default: 0.5 * **anchorY** (number) - The vertical anchor point of the UI (0: top, 0.5: center, 1.0: bottom). Default: 0.5 * **castShadow** (boolean) - Determines if the UI casts a shadow. Default: true * **height** (number) - Height in pixels for rendering the UI. Only used when `useWidgetSize` is false. Default: 90 * **players** (PlayerPermission) - Determines which players can see the UI. Defaults to all players. * **position** (Vector) - The position of the UI element. Relative to the object center when attached to an object. * **presentationStyle** (number) - Defines how the UI is presented, using values from `UIPresentationStyle`. * **rotation** (Rotator) - The rotation for this component. Relative to the object rotation when attached to an object. * **scale** (number) - The scale of this component. At scale 1, one pixel corresponds to one millimeter. Relative to the object scale when attached to an object. Default: 1 * **twoSided** (boolean) - Whether the UI is rendered on both sides. * **useTransparency** (boolean) - Whether to use transparency for the UI. * **useWidgetSize** (boolean) - If true, the UI element's size will match the widget's size. * **widget** (Widget) - The widget component attached to this UI element. * **width** (number) - Width in pixels to use for rendering the UI. Only used when `useWidgetSize` is false. Default: 90 * **zoomVisibility** (ZoomVisibility) - Determines visibility based on zoom level. ### Methods * **clone()**: Creates a clone of the UI element. ``` -------------------------------- ### GET /api/gameTime Source: https://github.com/plasticity-studios/tabletop-playground-api/blob/master/docs/classes/_api_.gameworld.html Retrieves the current game time in seconds since the session started. ```APIDOC ## GET /api/gameTime ### Description Retrieves the current game time in seconds since the session started. ### Method GET ### Endpoint /api/gameTime ### Parameters #### Query Parameters None #### Request Body None ### Response #### Success Response (200) - **time** (number) - The time in seconds since the game session was started. #### Response Example ```json { "time": 123.45 } ``` ``` -------------------------------- ### Package API Source: https://github.com/plasticity-studios/tabletop-playground-api/blob/master/docs/classes/_api_.package.html This section details the methods available for interacting with Tabletop Playground packages, including retrieving package information and managing assets. ```APIDOC ## Package Class Methods ### allow #### Description Starts a request to allow the package. If some players don't have the package installed, they will be asked to subscribe to the package. If all players already have the package installed, it will be allowed immediately. #### Method `allow()` #### Endpoint N/A (Method within a Package object) #### Parameters None #### Request Example ```javascript // Assuming 'myPackage' is an instance of the Package class myPackage.allow(); ``` #### Response * **Returns**: `void` ### getFontFiles #### Description Returns filenames (including relative paths) for all fonts in this package. #### Method `getFontFiles()` #### Endpoint N/A (Method within a Package object) #### Parameters None #### Request Example ```javascript // Assuming 'myPackage' is an instance of the Package class const fontFiles = myPackage.getFontFiles(); console.log(fontFiles); ``` #### Response * **Returns**: `string[]` - An array of font filenames. ### getModelFiles #### Description Returns filenames (including relative paths) for all models in this package. #### Method `getModelFiles()` #### Endpoint N/A (Method within a Package object) #### Parameters None #### Request Example ```javascript // Assuming 'myPackage' is an instance of the Package class const modelFiles = myPackage.getModelFiles(); console.log(modelFiles); ``` #### Response * **Returns**: `string[]` - An array of model filenames. ### getName #### Description Returns the name of the package. #### Method `getName()` #### Endpoint N/A (Method within a Package object) #### Parameters None #### Request Example ```javascript // Assuming 'myPackage' is an instance of the Package class const packageName = myPackage.getName(); console.log(packageName); ``` #### Response * **Returns**: `string` - The name of the package. ### getScriptFiles #### Description Returns filenames (including relative paths) for all scripts in this package. #### Method `getScriptFiles()` #### Endpoint N/A (Method within a Package object) #### Parameters None #### Request Example ```javascript // Assuming 'myPackage' is an instance of the Package class const scriptFiles = myPackage.getScriptFiles(); console.log(scriptFiles); ``` #### Response * **Returns**: `string[]` - An array of script filenames. ### getSoundFiles #### Description Returns filenames (including relative paths) for all sounds in this package. #### Method `getSoundFiles()` #### Endpoint N/A (Method within a Package object) #### Parameters None #### Request Example ```javascript // Assuming 'myPackage' is an instance of the Package class const soundFiles = myPackage.getSoundFiles(); console.log(soundFiles); ``` #### Response * **Returns**: `string[]` - An array of sound filenames. ### getTemplateIds #### Description Returns the unique ids of all templates in this package. #### Method `getTemplateIds()` #### Endpoint N/A (Method within a Package object) #### Parameters None #### Request Example ```javascript // Assuming 'myPackage' is an instance of the Package class const templateIds = myPackage.getTemplateIds(); console.log(templateIds); ``` #### Response * **Returns**: `string[]` - An array of template IDs. ### getTextureFiles #### Description Returns filenames (including relative paths) for all textures in this package. #### Method `getTextureFiles()` #### Endpoint N/A (Method within a Package object) #### Parameters None #### Request Example ```javascript // Assuming 'myPackage' is an instance of the Package class const textureFiles = myPackage.getTextureFiles(); console.log(textureFiles); ``` #### Response * **Returns**: `string[]` - An array of texture filenames. ### getUniqueId #### Description Returns the unique id of the package. This id can be found in the manifest.json file in the package directory. #### Method `getUniqueId()` #### Endpoint N/A (Method within a Package object) #### Parameters None #### Request Example ```javascript // Assuming 'myPackage' is an instance of the Package class const packageId = myPackage.getUniqueId(); console.log(packageId); ``` #### Response * **Returns**: `string` - The unique ID of the package. ``` -------------------------------- ### HttpRequest - setMethod Source: https://github.com/plasticity-studios/tabletop-playground-api/blob/master/docs/classes/_api_.httprequest.html Sets the HTTP method for the request. Allowed methods are GET, PUT, POST, and DELETE. Defaults to GET if not specified. ```APIDOC ## POST /api/setMethod ### Description Sets the method used by the request. Allowed methods are GET, PUT, POST, and DELETE. Should be set before calling [process](_api_.httprequest.html#process). If not specified, GET is assumed. ### Method POST ### Endpoint /api/setMethod ### Parameters #### Query Parameters - **verb** (string) - Required - Method to use (e.g., GET, POST, PUT, DELETE) ### Request Example ```json { "verb": "POST" } ``` ### Response #### Success Response (200) - **message** (string) - Indicates successful setting of the HTTP method. ``` -------------------------------- ### Fetch Resources Source: https://github.com/plasticity-studios/tabletop-playground-api/blob/master/docs/modules/_api_.html Fetches resources from a specified URL with optional configuration. This method is asynchronous and returns a Promise that resolves to a FetchResponse object. ```APIDOC ## GET /api/fetch ### Description Fetches resources from a url according to the given options, returning a promise that will resolve to the response. ### Method GET ### Endpoint /api/fetch ### Parameters #### Query Parameters - **url** (string) - Required - The URL to fetch - **options** (FetchOptions) - Optional - Options for how to call the URL ### Request Example ```javascript fetch('https://postman-echo.com/get?foo1=bar1&foo2=bar2').then(res => console.log(JSON.stringify(res.json()))) ``` ### Response #### Success Response (200) - **FetchResponse** (object) - An object containing the response from the fetched URL. #### Response Example ```json { "example": "response body" } ``` ``` -------------------------------- ### getObjectType Source: https://github.com/plasticity-studios/tabletop-playground-api/blob/master/docs/classes/_api_.cardholder.html Get the object's type. ```APIDOC ## GET /api/objects/{id}/object_type ### Description Get the object's type. Possible values are defined in ObjectType. ### Method GET ### Endpoint /api/objects/{id}/object_type ### Response #### Success Response (200) - **number** - The type of the object. #### Response Example { "example": 1 } ``` -------------------------------- ### Perform Capsule Trace in TypeScript Source: https://github.com/plasticity-studios/tabletop-playground-api/blob/master/docs/classes/_api_.gameworld.html Finds all object hits with a capsule that is moved along a line. It requires start and end points, capsule extent, and an optional orientation. Returns an array of TraceHit objects, ordered by distance to the start. ```typescript capsuleTrace(start: Vector | [number, number, number], end: Vector | [number, number, number], extent: Vector | [number, number, number], orientation?: Rotator | [number, number, number]): TraceHit[] ``` -------------------------------- ### GameObject Methods Source: https://github.com/plasticity-studios/tabletop-playground-api/blob/master/docs/classes/_api_.staticobject.html This section details various methods for interacting with and retrieving information about GameObject instances. ```APIDOC ## addDrawingLine ### Description Add a drawn line to the object. Lines are geometry and can increase the size of the object returned by [getSize](_api_.staticobject.html#getsize) and [getExtent](_api_.staticobject.html#getextent). Returns whether the line was added successfully. It can't be added if no table exists, if the [DrawingLine](_api_.drawingline.html) is invalid, or if there are already too many lines drawn on the table and the new line would go beyond the limit. ### Method POST ### Endpoint /api/objects/{objectId}/drawingLines ### Parameters #### Request Body - **line** (DrawingLine) - The drawing line object to add ### Response #### Success Response (200) - **success** (boolean) - Indicates if the line was added successfully. ### Request Example ```json { "line": { "points": [ {"x": 0, "y": 0, "z": 0}, {"x": 1, "y": 1, "z": 1} ], "color": "#FF0000", "width": 2 } } ``` ### Response Example ```json { "success": true } ``` ``` ```APIDOC ## addUI ### Description Attach a new UI element object to this object. ### Method POST ### Endpoint /api/objects/{objectId}/ui ### Parameters #### Request Body - **element** (UIElement) - The UI element to attach ### Response #### Success Response (200) - **index** (number) - The index of the attached UI element ### Request Example ```json { "element": { "type": "Button", "text": "Click Me", "position": {"x": 0, "y": 0}, "size": {"width": 100, "height": 50} } } ``` ### Response Example ```json { "index": 0 } ``` ``` ```APIDOC ## attachUI ### Description Deprecated. Alias for [addUI](_api_.staticobject.html#addui). ### Method POST ### Endpoint /api/objects/{objectId}/attachUI ### Parameters #### Request Body - **element** (UIElement) - The UI element to attach ### Response #### Success Response (200) - **index** (number) - The index of the attached UI element ### Request Example ```json { "element": { "type": "Label", "text": "Status: Active", "position": {"x": 10, "y": 10}, "size": {"width": 150, "height": 30} } } ``` ### Response Example ```json { "index": 1 } ``` ``` ```APIDOC ## destroy ### Description Destroy the object. ### Method DELETE ### Endpoint /api/objects/{objectId} ### Response #### Success Response (200) - **message** (string) - Confirmation message that the object was destroyed. ### Response Example ```json { "message": "Object destroyed successfully." } ``` ``` ```APIDOC ## getAllSnapPoints ### Description Return an array with all snap points of the object. ### Method GET ### Endpoint /api/objects/{objectId}/snapPoints ### Response #### Success Response (200) - **snapPoints** (Array) - An array of SnapPoint objects associated with the GameObject. ### Response Example ```json { "snapPoints": [ { "id": "snap1", "position": {"x": 0, "y": 0, "z": 0}, "rotation": {"pitch": 0, "yaw": 0, "roll": 0} }, { "id": "snap2", "position": {"x": 1, "y": 0, "z": 0}, "rotation": {"pitch": 0, "yaw": 90, "roll": 0} } ] } ``` ``` ```APIDOC ## getAttachedUIs ### Description Deprecated. Alias for [getUIs](_api_.staticobject.html#getuis). ### Method GET ### Endpoint /api/objects/{objectId}/attachedUIs ### Response #### Success Response (200) - **uis** (Array) - An array of UIElement objects attached to the GameObject. ### Response Example ```json { "uis": [ { "type": "Button", "text": "Close", "position": {"x": 5, "y": 5}, "size": {"width": 80, "height": 40} } ] } ``` ``` ```APIDOC ## getBounciness ### Description Return the object's bounciness value. ### Method GET ### Endpoint /api/objects/{objectId}/bounciness ### Response #### Success Response (200) - **bounciness** (number) - The bounciness value of the object. ### Response Example ```json { "bounciness": 0.7 } ``` ``` ```APIDOC ## getDensity ### Description Return the object's density value. ### Method GET ### Endpoint /api/objects/{objectId}/density ### Response #### Success Response (200) - **density** (number) - The density value of the object. ### Response Example ```json { "density": 1.5 } ``` ``` ```APIDOC ## getDescription ### Description Return the object's description. ### Method GET ### Endpoint /api/objects/{objectId}/description ### Response #### Success Response (200) - **description** (string) - The description of the object. ### Response Example ```json { "description": "A detailed description of the game object." } ``` ``` ```APIDOC ## getDrawingLines ### Description Return all drawing lines on the object. ### Method GET ### Endpoint /api/objects/{objectId}/drawingLines ### Response #### Success Response (200) - **drawingLines** (Array) - An array of DrawingLine objects associated with the GameObject. ### Response Example ```json { "drawingLines": [ { "points": [ {"x": 0, "y": 0, "z": 0}, {"x": 0.5, "y": 0.5, "z": 0.5} ], "color": "#00FF00", "width": 1 } ] } ``` ``` -------------------------------- ### Perform Box Trace in TypeScript Source: https://github.com/plasticity-studios/tabletop-playground-api/blob/master/docs/classes/_api_.gameworld.html Finds all object hits with a box that is moved along a line. It takes start and end points, box dimensions, and an optional orientation. Returns an array of TraceHit objects, ordered by distance to the start. ```typescript boxTrace(start: Vector | [number, number, number], end: Vector | [number, number, number], extent: Vector | [number, number, number], orientation?: Rotator | [number, number, number]): TraceHit[] ``` -------------------------------- ### Create and Manage UI Elements with Widgets Source: https://context7.com/plasticity-studios/tabletop-playground-api/llms.txt Demonstrates the creation of interactive UI elements attached to objects or floating in the world. It covers initializing UIElement, adding various widgets like Text, Button, TextBox, CheckBox, Slider, and ImageWidget, and arranging them using layout containers (VerticalBox, Border) and Canvas. It also shows how to attach UI to objects, add to the world, update, and remove UI elements. ```javascript const { world, UIElement, Text, Button, VerticalBox, HorizontalBox, Border, Canvas, TextBox, CheckBox, Slider, ImageWidget, Color, Vector, Rotator, HorizontalAlignment, VerticalAlignment, TextJustification } = require('@tabletop-playground/api'); // Create a basic UI element const ui = new UIElement(); ui.position = new Vector(0, 0, 5); ui.rotation = new Rotator(0, 0, 0); ui.scale = 1.0; ui.useWidgetSize = true; // Text widget const label = new Text() .setText('Hello World') .setFontSize(16) .setBold(true) .setTextColor(new Color(1, 1, 1, 1)) .setJustification(TextJustification.Center); // Button widget const button = new Button() .setText('Click Me') .setFontSize(14); button.onClicked.add((btn, player) => { console.log(`${player.getName()} clicked the button`); }); // Text input const textBox = new TextBox() .setText('Enter text here') .setMaxLength(100) .setFontSize(12); textBox.onTextCommitted.add((box, player, text, usingEnter) => { console.log(`Text submitted: ${text}`); }); // Checkbox const checkBox = new CheckBox() .setText('Enable feature') .setIsChecked(false); checkBox.onCheckStateChanged.add((box, player, isChecked) => { console.log(`Checked: ${isChecked}`); }); // Slider const slider = new Slider() .setMinValue(0) .setMaxValue(100) .setValue(50) .setStepSize(1); slider.onValueChanged.add((sldr, player, value) => { console.log(`Value: ${value}`); }); // Image widget const image = new ImageWidget() .setImageURL('https://example.com/image.png') .setImageSize(100, 100); // Layout containers const verticalBox = new VerticalBox() .setChildDistance(5) .addChild(label) .addChild(button) .addChild(textBox) .addChild(checkBox) .addChild(slider); // Border wrapper const border = new Border() .setColor(new Color(0.2, 0.2, 0.2, 0.8)) .setChild(verticalBox); // Set widget and attach to object ui.widget = border; refObject.addUI(ui); // Canvas for absolute positioning const canvas = new Canvas(); canvas.addChild(new Text().setText('Top Left'), 0, 0, 100, 30); canvas.addChild(new Button().setText('Bottom'), 0, 200, 150, 40); const canvasUI = new UIElement(); canvasUI.widget = canvas; canvasUI.useWidgetSize = false; canvasUI.width = 200; canvasUI.height = 250; // Add to world instead of object world.addUI(canvasUI); // Update UI after changes refObject.updateUI(ui); // Remove UI refObject.removeUI(0); ``` -------------------------------- ### Play Sound at Location Source: https://github.com/plasticity-studios/tabletop-playground-api/blob/master/docs/classes/_api_.sound.html Starts playing a sound originating from a specified 3D position. Allows configuration of start time, volume, loop, and player permissions. Playback begins once the sound is loaded if not already. ```typescript playAtLocation(position: Vector | [number, number, number], startTime?: number, volume?: number, loop?: boolean, players?: PlayerPermission): void; ``` -------------------------------- ### Object Scale Management Source: https://github.com/plasticity-studios/tabletop-playground-api/blob/master/docs/classes/_api_.gameobject.html Methods for setting an object's scale instantly. ```APIDOC ## POST /api/objects/{id}/scale ### Description Sets the object's scale instantly. ### Method POST ### Endpoint /api/objects/{id}/scale ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the object. #### Request Body - **scale** (Vector | [number, number, number]) - Required - The new scale of the object. Can be a Vector object or an array of [x, y, z] values. ### Request Example ```json { "scale": {"x": 2, "y": 2, "z": 2} } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the operation was successful. #### Response Example ```json { "status": "success" } ``` ``` -------------------------------- ### GET /api/players/byName/{name} Source: https://github.com/plasticity-studios/tabletop-playground-api/blob/master/docs/classes/_api_.gameworld.html Retrieves a specific player by their name. ```APIDOC ## GET /api/players/byName/{name} ### Description Retrieves a specific player by their name. ### Method GET ### Endpoint /api/players/byName/{name} ### Parameters #### Path Parameters - **name** (string) - Required - The name of the player. #### Query Parameters None #### Request Body None ### Response #### Success Response (200) - **Player** (object) - The player object if found. #### Response Example ```json { "id": "player-1", "name": "Alice", "slot": 0 } ``` #### Not Found Response (404) - Returns an empty response or an error message if the player is not found. ``` -------------------------------- ### TextBox Class Documentation Source: https://github.com/plasticity-studios/tabletop-playground-api/blob/master/docs/classes/_api_.textbox.html Provides details about the TextBox class, its inheritance, properties, and methods. ```APIDOC ## Class TextBox An editable text box UI element ### Hierarchy * [TextWidgetBase](_api_.textwidgetbase.html) * TextBox ### Properties * [onTextChanged](_api_.textbox.html#ontextchanged) * [onTextCommitted](_api_.textbox.html#ontextcommitted) ### Methods * [getFontFileName](_api_.textbox.html#getfontfilename) * [getFontPackageId](_api_.textbox.html#getfontpackageid) * [getFontSize](_api_.textbox.html#getfontsize) * [getInputType](_api_.textbox.html#getinputtype) * [getMaxLength](_api_.textbox.html#getmaxlength) * [getOwningObject](_api_.textbox.html#getowningobject) * [getParent](_api_.textbox.html#getparent) * [getText](_api_.textbox.html#gettext) * [getTextColor](_api_.textbox.html#gettextcolor) * [isBackgroundTransparent](_api_.textbox.html#isbackgroundtransparent) * [isBold](_api_.textbox.html#isbold) * [isEnabled](_api_.textbox.html#isenabled) * [isItalic](_api_.textbox.html#isitalic) * [isSelectTextOnFocus](_api_.textbox.html#isselecttextonfocus) * [isVisible](_api_.textbox.html#isvisible) * [setBackgroundTransparent](_api_.textbox.html#setbackgroundtransparent) * [setBold](_api_.textbox.html#setbold) * [setEnabled](_api_.textbox.html#setenabled) * [setFont](_api_.textbox.html#setfont) * [setFontSize](_api_.textbox.html#setfontsize) * [setInputType](_api_.textbox.html#setinputtype) * [setItalic](_api_.textbox.html#setitalic) * [setMaxLength](_api_.textbox.html#setmaxlength) * [setSelectTextOnFocus](_api_.textbox.html#setselecttextonfocus) * [setText](_api_.textbox.html#settext) * [setTextColor](_api_.textbox.html#settextcolor) * [setVisible](_api_.textbox.html#setvisible) ## Properties ### onTextChanged * Type: [MulticastDelegate](_api_.multicastdelegate.html)<(textBox: this, player: [Player](_api_.player.html), text: string) => void> * Defined in: [index.d.ts:4583](https://github.com/plasticity-studios/tabletop-playground-api/blob/6fdfc35/index.d.ts#L4583) Called when the edited text changes. * **param** The text box where the text changed * **param** The player that changed the text. undefined if the text was changed through [setText](_api_.textbox.html#settext). * **param** The new text ### onTextCommitted * Type: [MulticastDelegate](_api_.multicastdelegate.html)<(textBox: this, player: [Player](_api_.player.html), text: string, usingEnter: boolean) => void> * Defined in: [index.d.ts:4592](https://github.com/plasticity-studios/tabletop-playground-api/blob/6fdfc35/index.d.ts#L4592) Called when the edited text is committed (by pressing Enter or deselecting the widget). * **param** The text box where the text was committed * **param** The player that committed the text. undefined if the text was committed through [setText](_api_.textbox.html#settext). * **param** The new text * **param** True if the user committed the text using the enter key, false if it was committed for another reason (usually because the text field lost focus) ## Methods ### getFontFileName * getFontFileName(): string * Inherited from [TextWidgetBase](_api_.textwidgetbase.html).[getFontFileName](_api_.textwidgetbase.html#getfontfilename) * Defined in: [index.d.ts:3822](https://github.com/plasticity-studios/tabletop-playground-api/blob/6fdfc35/index.d.ts#L3822) Return the TrueType font file name used for the text. Empty if no custom font is used. #### Returns * string ### getFontPackageId * getFontPackageId(): string * Inherited from [TextWidgetBase](_api_.textwidgetbase.html).[getFontPackageId](_api_.textwidgetbase.html#getfontpackageid) * Defined in: [index.d.ts:3818](https://github.com/plasticity-studios/tabletop-playground-api/blob/6fdfc35/index.d.ts#L3818) Return the id of the package that contains the TrueType font file name used for the text. Empty if no custom font is used or no package is specified (and the package containing the script is used). #### Returns * string ### getFontSize * getFontSize(): number * Inherited from [TextWidgetBase](_api_.textwidgetbase.html).[getFontSize](_api_.textwidgetbase.html#getfontsize) * Defined in: [index.d.ts:3813](https://github.com/plasticity-studios/tabletop-playground-api/blob/6fdfc35/index.d.ts#L3813) Return the font size #### Returns * number ``` -------------------------------- ### Method: addUI Source: https://github.com/plasticity-studios/tabletop-playground-api/blob/master/docs/classes/_api_.cardholder.html Attaches a new UI element object to this object. ```APIDOC ## Method: addUI ### Description Attach a new UI element object to this object. ### Parameters - **element** ([UIElement](_api_.uielement.html)) - The UI element to attach. ### Returns - **number** - The index of the attached UI element. ### Signature ```typescript addUI(element: UIElement): number ``` ``` -------------------------------- ### GET /api/gravityMultiplier Source: https://github.com/plasticity-studios/tabletop-playground-api/blob/master/docs/classes/_api_.gameworld.html Retrieves the current gravity multiplier for the game. ```APIDOC ## GET /api/gravityMultiplier ### Description Retrieves the current gravity multiplier for the game. ### Method GET ### Endpoint /api/gravityMultiplier ### Parameters #### Query Parameters None #### Request Body None ### Response #### Success Response (200) - **multiplier** (number) - The current gravity multiplier. #### Response Example ```json { "multiplier": 1.0 } ``` ``` -------------------------------- ### GameWorld Class Overview Source: https://github.com/plasticity-studios/tabletop-playground-api/blob/master/docs/classes/_api_.gameworld.html Provides an overview of the GameWorld class, its purpose, and how to access its methods through the global 'world' object. ```APIDOC ## GameWorld Class ### Description The game world. Contains all global methods of the API. You don't create an instance of this class directly, instead use the [world](../modules/_api_.html#world) object that always exists. ### Hierarchy * GameWorld ### Properties * [grid](_api_.gameworld.html#grid) * [lighting](_api_.gameworld.html#lighting) * [turns](_api_.gameworld.html#turns) ``` -------------------------------- ### HorizontalBox - Get Parent Source: https://github.com/plasticity-studios/tabletop-playground-api/blob/master/docs/classes/_api_.horizontalbox.html Retrieves the parent container of this HorizontalBox. ```APIDOC ## GET /api/ui/horizontalbox/getparent ### Description Gets the parent container of this HorizontalBox. ### Method GET ### Endpoint /api/ui/horizontalbox/getparent ### Parameters None ### Request Example ```json {} ``` ### Response #### Success Response (200) - **parent** (Panel) - The parent Panel object. #### Response Example ```json { "parent": {"type": "Panel", "id": "mainContainer"} } ``` ``` -------------------------------- ### Play Sound (No Location) Source: https://github.com/plasticity-studios/tabletop-playground-api/blob/master/docs/classes/_api_.sound.html Starts playing a sound without a specific spatial origin. Supports setting start time, volume, loop behavior, and player permissions. If the sound is not loaded, it will play upon loading completion. ```typescript play(startTime?: number, volume?: number, loop?: boolean, players?: PlayerPermission): void; ``` -------------------------------- ### LayoutBox Class Methods Source: https://github.com/plasticity-studios/tabletop-playground-api/blob/master/docs/classes/_api_.layoutbox.html This section details the methods available for the LayoutBox class, including getters and setters for its properties. ```APIDOC ## LayoutBox Class Methods This section details the methods available for the LayoutBox class, including getters and setters for its properties. ### getBottomPadding * `getBottomPadding(): number` Return the number of padding pixels on the left of the child widget. #### Returns number ### getChild * `getChild(): Widget | undefined` Return the child widget. Returns undefined if no child has been set for this LayoutBox. #### Returns Widget | undefined ### getHorizontalAlignment * `getHorizontalAlignment(): number` Return the horizontal alignment of the child widget within the LayoutBox, as defined by [HorizontalAlignment](../enums/_api_.horizontalalignment.html). #### Returns number ### getLeftPadding * `getLeftPadding(): number` Return the number of padding pixels on the left of the child widget. #### Returns number ### getMaximumHeight * `getMaximumHeight(): number` Return the maximum height that this box should get. Returns -1 if no maximum is set. #### Returns number ### getMaximumWidth * `getMaximumWidth(): number` Return the maximum width that this box should get. Returns -1 if no maximum is set. #### Returns number ### getMinimumHeight * `getMinimumHeight(): number` Return the minimum height that this box should get. #### Returns number ### getMinimumWidth * `getMinimumWidth(): number` Return the minimum width that this box should get. #### Returns number ### getOverrideHeight * `getOverrideHeight(): number` Return the override height of the widget. Returns -1 if no override is set. #### Returns number ### getOverrideWidth * `getOverrideWidth(): number` Return the override width of the widget. Returns -1 if no override is set. #### Returns number ### getOwningObject * `getOwningObject(): Widget | undefined` Return the owning widget of this object. Returns undefined if the widget is not owned by any other widget (e.g. it is on the Canvas). #### Returns Widget | undefined ### getParent * `getParent(): Widget | undefined` Return the parent widget of this widget. Returns undefined if the widget is not parented by any other widget (e.g. it is on the Canvas). #### Returns Widget | undefined ### getRightPadding * `getRightPadding(): number` Return the number of padding pixels on the right of the child widget. #### Returns number ### getTopPadding * `getTopPadding(): number` Return the number of padding pixels on the top of the child widget. #### Returns number ### getVerticalAlignment * `getVerticalAlignment(): number` Return the vertical alignment of the child widget within the LayoutBox, as defined by [VerticalAlignment](../enums/_api_.verticalalignment.html). #### Returns number ### isEnabled * `isEnabled(): boolean` Return true if this widget is enabled, false otherwise. #### Returns boolean ### isVisible * `isVisible(): boolean` Return true if this widget is visible, false otherwise. #### Returns boolean ### setChild * `setChild(child: Widget): void` Set the child widget of this LayoutBox. Any previous child will be removed. #### Parameters * **child** (Widget) - Required - The widget to set as the child. ### setEnabled * `setEnabled(enabled: boolean): void` Enable or disable this widget. #### Parameters * **enabled** (boolean) - Required - True to enable, false to disable. ### setHorizontalAlignment * `setHorizontalAlignment(alignment: number): void` Set the horizontal alignment of the child widget within the LayoutBox. Use values from [HorizontalAlignment](../enums/_api_.horizontalalignment.html). #### Parameters * **alignment** (number) - Required - The horizontal alignment value. ### setMaximumHeight * `setMaximumHeight(height: number): void` Set the maximum height that this box should get. Set to -1 to remove the maximum. #### Parameters * **height** (number) - Required - The maximum height in pixels. ### setMaximumWidth * `setMaximumWidth(width: number): void` Set the maximum width that this box should get. Set to -1 to remove the maximum. #### Parameters * **width** (number) - Required - The maximum width in pixels. ### setMinimumHeight * `setMinimumHeight(height: number): void` Set the minimum height that this box should get. #### Parameters * **height** (number) - Required - The minimum height in pixels. ### setMinimumWidth * `setMinimumWidth(width: number): void` Set the minimum width that this box should get. #### Parameters * **width** (number) - Required - The minimum width in pixels. ### setOverrideHeight * `setOverrideHeight(height: number): void` Set the override height of the widget. Set to -1 to remove the override. #### Parameters * **height** (number) - Required - The override height in pixels. ### setOverrideWidth * `setOverrideWidth(width: number): void` Set the override width of the widget. Set to -1 to remove the override. #### Parameters * **width** (number) - Required - The override width in pixels. ### setPadding * `setPadding(padding: number): void` Set the padding on all sides of the child widget. #### Parameters * **padding** (number) - Required - The padding in pixels. ### setVerticalAlignment * `setVerticalAlignment(alignment: number): void` Set the vertical alignment of the child widget within the LayoutBox. Use values from [VerticalAlignment](../enums/_api_.verticalalignment.html). #### Parameters * **alignment** (number) - Required - The vertical alignment value. ### setVisible * `setVisible(visible: boolean): void` Set the visibility of this widget. #### Parameters * **visible** (boolean) - Required - True to make visible, false to hide. ``` -------------------------------- ### Object Tags Source: https://github.com/plasticity-studios/tabletop-playground-api/blob/master/docs/classes/_api_.dice.html Get the list of tags associated with a game object. ```APIDOC ## GET /api/objects/{objectId}/tags ### Description Returns the current list of tags assigned to the object. ### Method GET ### Endpoint `/api/objects/{objectId}/tags` ### Parameters #### Path Parameters - **objectId** (string) - Required - The unique identifier of the object. ### Response #### Success Response (200) - **tags** (string[]) - An array of strings representing the object's tags. #### Response Example ```json { "tags": ["tag1", "tag2", "important"] } ``` ``` -------------------------------- ### Container and Object Configuration API Source: https://github.com/plasticity-studios/tabletop-playground-api/blob/master/docs/classes/_api_.container.html This section covers methods for configuring container tags, object types, and other specific settings. ```APIDOC ## Container and Object Configuration API This API group provides methods for configuring various aspects of containers and objects, including tags, types, and metadata. ### Methods - **setContainerTags** - **Description**: Sets the tags for the container. - **Method**: PUT - **Endpoint**: N/A (Assumed to be a method call on a container object) - **Parameters**: - **tags** (string[]) - Required - An array of tags to set. - **setDescription** - **Description**: Sets the description for the object. - **Method**: PUT - **Endpoint**: N/A (Assumed to be a method call on an object) - **Parameters**: - **description** (string) - Required - The new description. - **setGroupId** - **Description**: Sets the group ID for the object. - **Method**: PUT - **Endpoint**: N/A (Assumed to be a method call on an object) - **Parameters**: - **groupId** (string) - Required - The new group ID. - **setId** - **Description**: Sets the ID for the object. - **Method**: PUT - **Endpoint**: N/A (Assumed to be a method call on an object) - **Parameters**: - **id** (string) - Required - The new ID. - **setMaxItems** - **Description**: Sets the maximum number of items allowed in the container. - **Method**: PUT - **Endpoint**: N/A (Assumed to be a method call on a container object) - **Parameters**: - **maxItems** (number) - Required - The maximum number of items. - **setMetallic** - **Description**: Sets the metallic property of the object. - **Method**: PUT - **Endpoint**: N/A (Assumed to be a method call on an object) - **Parameters**: - **metallic** (number) - Required - The metallic value. - **setName** - **Description**: Sets the name of the object. - **Method**: PUT - **Endpoint**: N/A (Assumed to be a method call on an object) - **Parameters**: - **name** (string) - Required - The new name. - **setObjectType** - **Description**: Sets the type of the object. - **Method**: PUT - **Endpoint**: N/A (Assumed to be a method call on an object) - **Parameters**: - **objectType** (string) - Required - The new object type. - **setOwningPlayerSlot** - **Description**: Sets the owning player slot for the object. - **Method**: PUT - **Endpoint**: N/A (Assumed to be a method call on an object) - **Parameters**: - **playerSlot** (number) - Required - The player slot number. - **setPrimaryColor** - **Description**: Sets the primary color of the object. - **Method**: PUT - **Endpoint**: N/A (Assumed to be a method call on an object) - **Parameters**: - **color** (Color) - Required - The new primary color. - **setRoughness** - **Description**: Sets the roughness property of the object. - **Method**: PUT - **Endpoint**: N/A (Assumed to be a method call on an object) - **Parameters**: - **roughness** (number) - Required - The roughness value. - **setSavedData** - **Description**: Sets saved data for the object. - **Method**: PUT - **Endpoint**: N/A (Assumed to be a method call on an object) - **Parameters**: - **data** (object) - Required - The data to save. - **setScript** - **Description**: Sets the script for the object. - **Method**: PUT - **Endpoint**: N/A (Assumed to be a method call on an object) - **Parameters**: - **scriptPackageId** (string) - Required - The ID of the script package. - **setSecondaryColor** - **Description**: Sets the secondary color of the object. - **Method**: PUT - **Endpoint**: N/A (Assumed to be a method call on an object) - **Parameters**: - **color** (Color) - Required - The new secondary color. - **setSnappingAllowed** - **Description**: Sets whether snapping is allowed for the object. - **Method**: PUT - **Endpoint**: N/A (Assumed to be a method call on an object) - **Parameters**: - **allowed** (boolean) - Required - True to allow snapping, false otherwise. - **setSurfaceType** - **Description**: Sets the surface type of the object. - **Method**: PUT - **Endpoint**: N/A (Assumed to be a method call on an object) - **Parameters**: - **surfaceType** (string) - Required - The new surface type. - **setTags** - **Description**: Sets the tags for the object. - **Method**: PUT - **Endpoint**: N/A (Assumed to be a method call on an object) - **Parameters**: - **tags** (string[]) - Required - An array of tags to set. - **setType** - **Description**: Sets the type of the object. - **Method**: PUT - **Endpoint**: N/A (Assumed to be a method call on an object) - **Parameters**: - **type** (string) - Required - The new type. - **setUI** - **Description**: Sets a UI element for the object. - **Method**: PUT - **Endpoint**: N/A (Assumed to be a method call on an object) - **Parameters**: - **uiElement** (UIElement) - Required - The UI element to set. ```