[API reference](https://jsprismarine.dev/api/index.md) / [@jsprismarine/prismarine](https://jsprismarine.dev/api/@jsprismarine/prismarine/index.md) / scripting/DataDrivenScreens

# scripting/DataDrivenScreens

## Classes

- [PropertyScreens](https://jsprismarine.dev/api/@jsprismarine/prismarine/scripting/DataDrivenScreens/classes/PropertyScreens.md)
- [VariableScreens](https://jsprismarine.dev/api/@jsprismarine/prismarine/scripting/DataDrivenScreens/classes/VariableScreens.md)

## Interfaces

### DataDrivenScreens

Defined in: [packages/prismarine/src/scripting/DataDrivenScreens.ts:93](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/scripting/DataDrivenScreens.ts#L93)

One client's `@minecraft/server-ui` data-driven screens on the wire, as the pinned Bedrock
Dedicated Server sends them at the client's protocol. A screen is one property of the client's
`minecraft` data store, which the server sets before it tells the client to show the screen; a
bound observable changes one path of it, and a screen the client reports closed has the
property cleared. The `data-driven-forms` scenario of `packages/parity` records these.

#### Methods

##### close()

> **close**(`formId`): `void`

Defined in: [packages/prismarine/src/scripting/DataDrivenScreens.ts:99](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/scripting/DataDrivenScreens.ts#L99)

Asks the client to close one screen.

###### Parameters

###### formId

`number`

###### Returns

`void`

##### closed()

> **closed**(`formId`): `boolean`

Defined in: [packages/prismarine/src/scripting/DataDrivenScreens.ts:109](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/scripting/DataDrivenScreens.ts#L109)

Takes a client's report that a screen closed, and clears the screen's property.

###### Parameters

###### formId

`number`

###### Returns

`boolean`

Whether the client had the screen open.

##### show()

> **show**(`formId`, `screen`): `void`

Defined in: [packages/prismarine/src/scripting/DataDrivenScreens.ts:95](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/scripting/DataDrivenScreens.ts#L95)

Sets the screen's property, sends the updates that follow it, and opens the screen.

###### Parameters

###### formId

`number`

###### screen

[`DataDrivenScreen`](https://jsprismarine.dev/api/@jsprismarine/script-host/host/world/index.md#datadrivenscreen)

###### Returns

`void`

##### update()

> **update**(`property`, `change`): `void`

Defined in: [packages/prismarine/src/scripting/DataDrivenScreens.ts:97](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/scripting/DataDrivenScreens.ts#L97)

Changes one path of a property the client was sent.

###### Parameters

###### property

`string`

###### change

[`DataDrivenPathValue`](https://jsprismarine.dev/api/@jsprismarine/script-host/host/world/index.md#datadrivenpathvalue)

###### Returns

`void`

##### written()

> **written**(`payload`): [`DataDrivenWrite`](#datadrivenwrite) \| `undefined`

Defined in: [packages/prismarine/src/scripting/DataDrivenScreens.ts:104](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/scripting/DataDrivenScreens.ts#L104)

Takes a client's write to a path of an open screen's property.

###### Parameters

###### payload

###### update

[`DataStoreUpdate`](https://jsprismarine.dev/api/@jsprismarine/protocol/classes/DataStoreUpdate.md) \| `null` = `...`

`Update` before protocol 2259, the single data store update the client applies. `null` from 2259.

###### variableUpdate

[`DataStoreVariableUpdate`](https://jsprismarine.dev/api/@jsprismarine/protocol/index.md#datastorevariableupdate) \| `null` = `...`

`Update` from protocol 2259, keyed by variable name. `null` before 2259.

###### Returns

[`DataDrivenWrite`](#datadrivenwrite) \| `undefined`

The write, or undefined when it names no screen the client has open or is stale.

***

### DataDrivenWrite

Defined in: [packages/prismarine/src/scripting/DataDrivenScreens.ts:80](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/scripting/DataDrivenScreens.ts#L80)

A client's write to one path of an open screen's property.

#### Properties

##### path

> `readonly` **path**: `string`

Defined in: [packages/prismarine/src/scripting/DataDrivenScreens.ts:82](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/scripting/DataDrivenScreens.ts#L82)

##### property

> `readonly` **property**: `string`

Defined in: [packages/prismarine/src/scripting/DataDrivenScreens.ts:81](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/scripting/DataDrivenScreens.ts#L81)

##### value

> `readonly` **value**: [`DataDrivenLeaf`](https://jsprismarine.dev/api/@jsprismarine/script-host/host/world/index.md#datadrivenleaf)

Defined in: [packages/prismarine/src/scripting/DataDrivenScreens.ts:83](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/scripting/DataDrivenScreens.ts#L83)

## Variables

### SCREEN\_DATA\_STORE

> `const` **SCREEN\_DATA\_STORE**: `"minecraft"` = `'minecraft'`

Defined in: [packages/prismarine/src/scripting/DataDrivenScreens.ts:30](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/scripting/DataDrivenScreens.ts#L30)

The data store every `@minecraft/server-ui` screen's property lives in, as BDS names it.

## Functions

### closeReasonOf()

> **closeReasonOf**(`reason`): [`DataDrivenCloseReason`](https://jsprismarine.dev/api/@jsprismarine/script-host/host/world/index.md#datadrivenclosereason)

Defined in: [packages/prismarine/src/scripting/DataDrivenScreens.ts:42](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/scripting/DataDrivenScreens.ts#L42)

A client's close reason as the script host spells it.

#### Parameters

##### reason

[`DataDrivenScreenClosedReason`](https://jsprismarine.dev/api/@jsprismarine/protocol/index.md#datadrivenscreenclosedreason)

#### Returns

[`DataDrivenCloseReason`](https://jsprismarine.dev/api/@jsprismarine/script-host/host/world/index.md#datadrivenclosereason)

***

### dataDrivenScreensFor()

> **dataDrivenScreensFor**(`protocolVersion`, `send`): [`DataDrivenScreens`](#datadrivenscreens)

Defined in: [packages/prismarine/src/scripting/DataDrivenScreens.ts:381](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/scripting/DataDrivenScreens.ts#L381)

The screens of a client at a protocol, in the data store layout its protocol uses: properties
up to 2225, variables from 2259.

#### Parameters

##### protocolVersion

`number`

##### send

(`packet`) => `void`

Sends one packet to the client.

#### Returns

[`DataDrivenScreens`](#datadrivenscreens)

***

### dataDrivenScreensOf()

> **dataDrivenScreensOf**(`session`): [`DataDrivenScreens`](#datadrivenscreens)

Defined in: [packages/prismarine/src/scripting/DataDrivenScreens.ts:390](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/scripting/DataDrivenScreens.ts#L390)

A session's data-driven screens, the same object for as long as it is connected.

#### Parameters

##### session

[`PlayerSession`](https://jsprismarine.dev/api/@jsprismarine/prismarine/player/PlayerSession/classes/PlayerSession.md)

#### Returns

[`DataDrivenScreens`](#datadrivenscreens)

***

### propertyValueOf()

> **propertyValueOf**(`value`): [`DataStorePropertyValue`](https://jsprismarine.dev/api/@jsprismarine/protocol/index.md#datastorepropertyvalue)

Defined in: [packages/prismarine/src/scripting/DataDrivenScreens.ts:48](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/scripting/DataDrivenScreens.ts#L48)

A screen's value as a `Data Store Change` carries it: a record is a map, an array a list, a
bigint an int64 and any other number a double.

#### Parameters

##### value

[`DataDrivenValue`](https://jsprismarine.dev/api/@jsprismarine/script-host/host/world/index.md#datadrivenvalue)

#### Returns

[`DataStorePropertyValue`](https://jsprismarine.dev/api/@jsprismarine/protocol/index.md#datastorepropertyvalue)

***

### variablesOf()

> **variablesOf**(`screen`): \[`string`, [`DataDrivenLeaf`](https://jsprismarine.dev/api/@jsprismarine/script-host/host/world/index.md#datadrivenleaf)\][]

Defined in: [packages/prismarine/src/scripting/DataDrivenScreens.ts:254](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/scripting/DataDrivenScreens.ts#L254)

A property's variables at protocol 2259, in the order the pinned BDS sends them: each value of
a control or group under its path, such as `layout[0].text`, and the layout's `length` as a
double. A `UIRawMessage` travels as its JSON text and a newline, after a `<path>.__is_object`
flag, and a dropdown's items as JSON text after a `<path>.__is_array` flag. A custom form also
carries `top_close_button_visible`.

#### Parameters

##### screen

[`DataDrivenScreen`](https://jsprismarine.dev/api/@jsprismarine/script-host/host/world/index.md#datadrivenscreen)

#### Returns

\[`string`, [`DataDrivenLeaf`](https://jsprismarine.dev/api/@jsprismarine/script-host/host/world/index.md#datadrivenleaf)\][]
