> ## Documentation Index
> Fetch the complete documentation index at: https://docs.awokenlabs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Exports

> Notifications, badges, the HUD, groups and SD cards from your own scripts.

Everything here is plain Lua and works from any resource, whether or not it has an app on the tablet. For putting your own app on the home screen, see [Building an app](/resources/awoken-tablet/building-an-app).

## Client

```lua theme={"dark"}
exports.awoken_tablet:Open()
exports.awoken_tablet:Close()
local open = exports.awoken_tablet:IsOpen()
exports.awoken_tablet:RefreshVisibility()   -- re-check which apps this player can see
```

`Open` respects `Config.DisableWhile`, so it will not open for a dead or handcuffed player.

## Notifications

```lua theme={"dark"}
exports.awoken_tablet:PushNotification(src, {
    appId   = 'awoken_courier',
    title   = 'New contract available',
    body    = 'Cargo run from Sandy Shores to LSI.',
    payload = {                       -- optional
        app  = 'awoken_courier',      -- tapping it opens this app
        data = { jobId = 4711 },      -- handed to the app when it opens
    },
})
```

Saved to the player's inbox, so it survives a reconnect, and shown as a pop-up if the tablet is closed. Returns the saved row, or `nil` if the player is not loaded or the payload was malformed.

The inbox badge updates itself. You do not need to call `SetAppBadge` as well.

## Badges

```lua theme={"dark"}
exports.awoken_tablet:SetAppBadge(src, 'awoken_courier', 3)
exports.awoken_tablet:ClearAppBadge(src, 'awoken_courier')
```

A small count on your app's tile, for a number your own script keeps. Pass `0` to clear.

## The HUD

A small card at the side of the screen that stays up while the tablet is closed. Built for live job state. One per player at a time, and calling `ShowHud` again replaces it.

```lua theme={"dark"}
exports.awoken_tablet:ShowHud(src, {
    title    = 'Courier route',
    subtitle = 'Active contract',     -- optional, defaults to "ACTIVE"
    stats    = {
        { label = 'Elapsed', value = '04:12' },
        { label = 'Parcels', value = '3 / 8' },
        { separator = true },
        { label = 'Payout',  value = '$2,400' },
    },
})

exports.awoken_tablet:HideHud(src)
```

Each entry in `stats` is a label and value row, or `{ separator = true }` for a thin divider. Update the card by calling `ShowHud` again with new values.

The colour is always the player's own tablet accent and cannot be set by the script. Players choose the side of the screen in the tablet's **Settings** app and can hide the card with the HUD key.

<Note>
  With `Config.Debug = true` in the tablet's config, `/awokenhud_test` pushes a sample card to you and `/awokenhud_clear` hides it.
</Note>

## Groups

```lua theme={"dark"}
local group = exports.awoken_tablet:GetGroup(src)
-- { id, name, leader, maxSize, members = { { src, identifier, name, role, online, joinedAt } }, version, createdAt }
-- nil when the player is not in a group

local inGroup = exports.awoken_tablet:IsInGroup(src)
local members = exports.awoken_tablet:GetGroupMembers(src)   -- {} when not in a group
```

`leader` is the leader's identifier. Everyone on the roster is online: a player who drops is removed.

```lua theme={"dark"}
exports.awoken_tablet:OnGroupChanged(function(src, group)
    -- fires when this player joins, leaves, is kicked, is promoted, or the group disbands
    -- group is nil when they are no longer in one
end)
```

Use this instead of polling.

<Note>
  Groups live in memory and are wiped by a server restart. A script that needs a crew to survive a restart should keep its own record.
</Note>

## SD cards

```lua theme={"dark"}
local ok, reason = exports.awoken_tablet:InstallSdReader(src)
```

Turns a player's stock tablet into a modded one and charges `Config.SdCards.install.price`. If the payment fails the stock tablet comes back and nothing is charged.

| `reason` | Meaning |
| - | - |
| `'disabled'` | SD cards are turned off in the config |
| `'no_tablet'` | They are not carrying a stock tablet |
| `'already_modded'` | Their tablet already has a reader |
| `'no_money'` | They cannot afford it |
| `'failed'` | The swap could not be completed |

```lua theme={"dark"}
local cards = exports.awoken_tablet:GetInstalledSdCards(src)
if cards['sd_chopshop'] then
    -- the card is seated in their tablet
end

local has = exports.awoken_tablet:HasTablet(src)
```

`HasTablet` is true for either tablet, stock or modded. Use it rather than checking for the item yourself, which misses the modded one.

## Apps

These are for scripts that put an app on the tablet. They are covered in [Building an app](/resources/awoken-tablet/building-an-app).

```lua theme={"dark"}
exports.awoken_tablet:RegisterApp(payload)
exports.awoken_tablet:DeregisterApp(id)
exports.awoken_tablet:RefreshVisibility(src)
exports.awoken_tablet:SendAppEvent(src, appId, action, payload)
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.