> For the complete documentation index, see [llms.txt](https://striga.gitbook.io/striga-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://striga.gitbook.io/striga-docs/striga-text-ui/exports-and-events.md).

# Exports & Events

Show interaction prompts and 3D prompts from your own scripts.

{% hint style="success" %}
**Quick start (client)**

Screen: `exports['striga-text-ui']:Show('[E] Open the garage')`\
World: `exports['striga-text-ui']:Add3D('garage', { coords = vec3(215.8, -810.1, 30.7), text = 'Open the garage', key = 'E' })`
{% endhint %}

All exports are **client** exports. Striga Text UI has no server exports.

{% hint style="warning" %}
**Text UI only shows the prompt.** Your script reads the key and decides what it does, for example `IsControlJustReleased(0, 38)` for `E`. The prompt and client distance checks are visual only: check distance, job, items and cooldowns again on the server before you act.
{% endhint %}

***

## Through striga-core (recommended)

If your script already uses **striga-core**, use `Core.showTextUI`. It works with whatever text UI the server owner picks, not only Striga Text UI.

```lua
local Core = exports['striga-core']:GetCore()

Core.showTextUI('Open the garage', { key = 'E', icon = 'car', position = 'right', style = 'info' })
Core.updateTextUI('Open the garage (2)')
Core.hideTextUI()

local open, text, owner = Core.isTextUIOpen()
```

The resource that shows a prompt owns it: only that resource can update or hide it (`Core.hideTextUI(true)` forces it). It is hidden when that resource stops.

***

## Prompt options

`Show` takes a text and an optional table:

| Field       | Type   | Default    | What it does                                                                |
| ----------- | ------ | ---------- | --------------------------------------------------------------------------- |
| `key`       | string | -          | Key shown in the tile: `E`, `G`, `F1`, `LMB`... (max 8 characters)          |
| `style`     | string | `'info'`   | `info` (theme color), `success`, `warning`, `error`                         |
| `icon`      | string | -          | Icon name: `door-open`, `car`, `hand`, `money-bill`, `gas-pump`, `box`...   |
| `iconColor` | string | type color | `#rrggbb`                                                                   |
| `position`  | string | config     | `left`, `right`, `top`, `bottom`. Used when the player's position is `auto` |

{% hint style="info" %}

* A text that starts with `[E]` shows `E` as the key: `'[E] Open door'`, `'[E] - Open door'` and `'[E]: Open door'` all work.
* Text is always shown as plain text. HTML tags and color codes (`~r~`, `^1`) are removed, `<br>` keeps the line break. Max 256 bytes.
* ox\_lib and QBCore names also work: `inform`, `primary` (= info), `warn` (= warning), `danger` (= error), `left-center`, `right-center`...
  {% endhint %}

***

## Screen prompt exports

### Show

Shows the prompt (or changes it if one is open). Returns `true` if it was shown.

{% tabs %}
{% tab title="Text" %}

```lua
exports['striga-text-ui']:Show('[E] Open the garage') -- '[E]' becomes the key
```

{% endtab %}

{% tab title="Options" %}

```lua
exports['striga-text-ui']:Show('Open the garage', {
    key = 'E',
    style = 'success',
    icon = 'car',
    position = 'right',
})
```

{% endtab %}
{% endtabs %}

### Update

New text, same options. Shows a new prompt if none is open.

```lua
exports['striga-text-ui']:Update('Open the garage (2)')
```

### Hide

Hides the prompt. Returns `false` if none was open.

```lua
exports['striga-text-ui']:Hide()
```

### IsOpen

```lua
local open, text = exports['striga-text-ui']:IsOpen()
```

### KeyPressed

Plays the key animation (fills with the main color and fades). The prompt comes back when the player is still at the same spot and no menu is open.

```lua
exports['striga-text-ui']:KeyPressed()
```

***

## 3D prompts

Pin a prompt to a spot or to an entity. Far away only its key shows, the **nearest** point in reach shows the whole prompt. The same code works in Flat (2D) and 3D mode.

| Export                | Returns   | What it does                                                 |
| --------------------- | --------- | ------------------------------------------------------------ |
| `Add3D(id, data)`     | `ok, err` | Adds a point. The same id from the same resource replaces it |
| `Update3D(id, patch)` | `ok, err` | Changes only the given fields (text, position, color...)     |
| `Remove3D(id)`        | `boolean` | Removes the point                                            |
| `Clear3D()`           | -         | Removes every point of your resource                         |
| `Has3D(id)`           | `boolean` | Whether the point exists                                     |

```lua
exports['striga-text-ui']:Add3D('atm_1', {
    coords = vec3(147.5, -1035.8, 29.3),
    text = 'Use the ATM', key = 'E', icon = 'money-bill',
})
```

{% hint style="info" %}
Every point field, entity points, reading the key, placing points and performance are on [3D Prompts](/striga-docs/striga-text-ui/3d-prompts.md).
{% endhint %}

***

## Events

Striga Text UI has no public events to trigger. It listens to these striga-core events by itself:

| Event                      | What it does                                                         |
| -------------------------- | -------------------------------------------------------------------- |
| `striga-core:ready`        | Registers Striga Text UI with striga-core again after a core restart |
| `striga-core:client:theme` | Uses the HUD theme color (until the player picks a color)            |

***

## For HUD and layout scripts

These exports are for scripts that want to control the look, like a HUD menu. Striga Tokyo HUD does not need them: it uses the striga-core settings hub. See [Settings Hub & Theme](/striga-docs/striga-core/settings-hub-and-theme.md).

| Export                   | What it does                                                                                                                                                       |
| ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `SetTheme(color)`        | Sets the theme color, e.g. `'#3b82f6'`. `nil` removes it. Removed by itself when your resource stops. Kept for older HUDs: the theme now comes through striga-core |
| `SetLayout(settings)`    | Changes the player's settings (saved on their PC). Returns `false` if nothing valid was given or settings are locked                                               |
| `SetPreview(true/false)` | Keeps a sample prompt on screen while your editor is open                                                                                                          |
| `GetSettings()`          | Returns the player's current settings                                                                                                                              |

```lua
exports['striga-text-ui']:SetLayout({
    style = 'pill',         -- card / pill / minimal
    keyStyle = 'tile',      -- keycap / tile / plain
    position = 'right',     -- auto / left / right / top / bottom
    opacity = 80,           -- 30 to 100
    size = 110,             -- 80 to 140
    blur = 8,               -- 0 to 16
    depth = '3d',           -- 2d / 3d
    accent = '#22d3ee',     -- player color, false = follow the HUD / config again
})

exports['striga-text-ui']:SetLayout({ reset = true }) -- back to config defaults

local s = exports['striga-text-ui']:GetSettings()
print(s.style, s.depth, s.locked)
```

{% content-ref url="/pages/PqKTMAkBHOBXwi0J8ktc" %}
[3D Prompts](/striga-docs/striga-text-ui/3d-prompts.md)
{% endcontent-ref %}

{% content-ref url="/pages/WgqW0IDpPGt1vlErksWX" %}
[Troubleshooting & FAQ](/striga-docs/striga-text-ui/troubleshooting-and-faq.md)
{% endcontent-ref %}
