Skip to content

合成物品

合成物品定義於 /data/craft.lua

物品以 key-value 配對的形式定義。Key 作為配方的 ID,並會在程式碼中引用。

選項

  • itemName string — 被合成物品的名稱

  • label? string — 設定此選項將覆蓋原始物品標籤

  • type? string — 設為 car 時,會以 itemName 的模型合成載具

  • category string — 用於在 NUI 中分組物品的標籤

  • description? string — 顯示於 NUI 的物品描述,若未定義則使用預設描述

  • stats? table[] — 顯示於描述下方的統計資訊,可用於顯示載具速度或武器傷害

    • icon string — 來自 Iconify 的任意圖示
    • color string — 圖示的 顏色
    • label string
    • value string
  • time number — 合成所需時間(秒)

  • level? number — 使用此配方所需等級,必須在 settings.lua 中將 enableLevel 設為 true

  • exp? number — 合成完成後給予玩家的經驗值,必須在 settings.lua 中將 enableLevel 設為 true

  • recipe table[] — 合成時消耗的物品

    • itemName string
    • count number
  • tools? table[] — 合成所需但不會被消耗的物品

    • itemName string
    • count number

範例

lua
local crafts = {
    ['bandage'] = {
        itemName = 'bandage',
        category = 'Medical',
        description = 'Used to stop bleeding and restore a small amount of health.',
        time = 5,
        level = 1,
        exp = 10,
        recipe = {
            {itemName = 'clothe', count = 5},            
        },
    },
    ['pistol'] = {
        itemName = 'weapon_pistol',
        category = 'Weapon',
        description = 'Used for basic self‑defense, offering moderate damage at close range.',
        time = 20,
        level = 3,
        exp = 50,
        recipe = {
            {itemName = 'copper', count = 5},
            {itemName = 'iron', count = 5},                   
        },
        tools = {
            {itemName = 'blueprint', count = 1},            
        },
    },
    ['t20'] = {
        itemName = 't20',
        label = 'T20',
        type = 'car',
        category = 'Vehicle',
        stats = {
            {icon = 'material-symbols:speed', label = 'Speed', value = '200 km/h', color = 'rgb(58, 196, 127)'},
        },
        time = 10,
        level = 5,
        recipe = {
            {itemName = 'iron', count = 30},            
        },
        tools = {
            {itemName = 'fixkit', count = 1}
        },
    }
}

return crafts