Item

Functions

GetItem(name)

ดึงข้อมูลไอเทมจากชื่อไอเทม

Parameter
Type
Description

name

string

ชื่อไอเทม

Returns: Item object

local item = AFUCore.GetItem("bread")
-- returns: { name = "bread", label = "ขนมปัง", weight = 1, ... }

GetItemLabel(name)

ดึงชื่อแสดงผลของไอเทม

Parameter
Type
Description

name

string

ชื่อไอเทม

Returns: string ชื่อแสดงผลของไอเทม

local label = AFUCore.GetItemLabel("bread")
-- returns: "ขนมปัง"

GetUsableItems()

ดึงรายชื่อไอเทมที่สามารถใช้งานได้

Returns: string[] รายชื่อไอเทมที่ใช้งานได้

local usableItems = AFUCore.GetUsableItems()
-- returns: ["bread", "water", "medkit", ...]

RegisterUsableItem(name, callback, ignoreOld)

ลงทะเบียนไอเทมที่สามารถใช้งานได้

Parameter
Type
Description

name

string

ชื่อไอเทม

callback

function

ฟังก์ชันที่จะทำงานเมื่อใช้ไอเทม

ignoreOld

boolean

ข้ามการตรวจสอบว่ามีการลงทะเบียนไว้แล้วหรือไม่

AFUCore.RegisterUsableItem("bread", function(source)
    local xPlayer = AFUCore.GetPlayerFromId(source)
    xPlayer.removeInventoryItem("bread", 1)
    xPlayer.setStatus("hunger", 200000)
end)

Item Object Structure

---@class Item
---@field name string คีย์ของไอเทม
---@field label string ชื่อแสดงผลของไอเทม
---@field description string คำอธิบายของไอเทม
---@field type ItemType ประเภทของไอเทม
---@field rarity ItemRarity ความหายากของไอเทม
---@field weight number น้ำหนักของไอเทม
---@field limit number จำนวนที่สามารถเก็บได้
---@field useable boolean สามารถใช้ได้หรือไม่
---@field canRemove boolean สามารถลบได้หรือไม่
---@field removeAfterUsed boolean ลบไอเทมหลังจากใช้หรือไม่

หมายเหตุ

  • ทุกไอเทมต้องมีการลงทะเบียนในฐานข้อมูลก่อน

  • สามารถ override ค่าต่างๆ ผ่าน Config.OverrideItems

  • มีระบบ Debug สำหรับตรวจสอบการสร้างไอเทม

Last updated