> For the complete documentation index, see [llms.txt](https://ak-scripts.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ak-scripts.gitbook.io/docs/yi-lai/markdown/ti-huan-kuang-jia-mo-ren-zhi/ox/wen-ben-textui.md).

# 文本（TextUI）

### ⚙️ 如何更改 ox\_lib 的默认文本 <a href="#ru-he-geng-gai-esx-de-mo-ren-tong-zhi" id="ru-he-geng-gai-esx-de-mo-ren-tong-zhi"></a>

> 本节将教你如何将 `ox_lib` **默认文本** 替换为 `ak-lib` **文本**。
>
> 由于 `ox_lib` 不同版本在函数结构上略有差异，本次示例基于 `ox_lib` `3.31.4` 进行讲解

### 🧭 步骤一：打开文本脚本文件

导航到以下路径：

```
ox_lib/resource/interface/client/textui.lua
```

***

### 🧩 步骤二：替换 ox\_lib 整个文本函数内容

```lua
local isOpen = false
local currentText

local function convertPosition(oxPosition)
    if not oxPosition then return nil end
    local positionMap = {
        ['right-center'] = 'middle-right',
        ['left-center'] = 'middle-left',
        ['top-center'] = 'top-center',
        ['bottom-center'] = 'bottom-center'
    }
    return positionMap[oxPosition] or oxPosition
end

local function convertIcon(icon)
    if not icon then return nil end
    if type(icon) == "string" then
        return icon
    end
    if type(icon) == "table" and icon[1] and icon[2] then
        local iconStr = (icon[1] or "") .. " " .. (icon[2] or "")
        iconStr = iconStr:match("^%s*(.-)%s*$")
        return iconStr ~= "" and iconStr or nil
    end
    return nil
end

local function convertStyle(style, iconColor, alignIcon)
    local result = {}
    if type(style) == "table" then
        for k, v in pairs(style) do
            result[k] = v
        end
    elseif type(style) == "string" then
    end
    if iconColor then
        result['--icon-color'] = iconColor
    end
    return result
end

function lib.showTextUI(text, options)
    if currentText == text then return end
    if not options then options = {} end
    local akLibOptions = {
        message = text,
        position = convertPosition(options.position),
        icon = convertIcon(options.icon),
        style = convertStyle(options.style, options.iconColor, options.alignIcon),
        duration = options.duration,
        sound = options.sound,
        volume = options.volume,
        id = options.id or "ox-lib-default"
    }
    exports['ak-lib']:TextUI(akLibOptions)
    currentText = text
    isOpen = true
end

function lib.hideTextUI()
    exports['ak-lib']:HideTextUI("ox-lib-default")
    isOpen = false
    currentText = nil
end

function lib.isTextUIOpen()
    local isOpen_ak, currentMsg = exports['ak-lib']:IsTextUIOpen("ox-lib-default")
    isOpen = isOpen_ak
    if not isOpen_ak then
        currentText = nil
    else
        currentText = currentMsg
    end
    return isOpen, currentText
end
```

***


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ak-scripts.gitbook.io/docs/yi-lai/markdown/ti-huan-kuang-jia-mo-ren-zhi/ox/wen-ben-textui.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
