# Item

아이템 오브젝트를 다루기 위한 객체에요.

## **이벤트**

<br>

| **UseEvent** |
| ------------ |

아이템 사용 시 호출되는 이벤트에요.\
연결함수 형식은 function(usePlayer), usePlayer 는 Player 객체 입니다.

\-- 샘플 --

```lua
local Item = Script.Parent

local function UseItem(player) --UseEvent에 연결된 함수는 Player 인자가 고정적으로 들어가요.
    print("Use Item")
end
Item.UseEvent:Connect(UseItem)  --아이템 사용시 호출할 함수를 연결해요.
```

<br>

| **EquipEvent** |
| -------------- |

아이템 장착 시 호출되는 이벤트에요.\
연결함수 형식은 function(equipPlayer), equipPlayer 는 Player 객체 입니다.

\-- 샘플 --

```lua
local Item = Script.Parent

local function EquipItem(player) --EquipEvent에 연결된 함수는 player 인자가 고정적으로 들어가요.

end
Item.EquipEvent:Connect(EquipItem) --아이템에 장착시 호출할 함수를 연결해요.
```

<br>

| **UnEquipEvent** |
| ---------------- |

아이템 탈착 시 호출되는 이벤트에요.\
연결함수 형식은 function(unequipPlayer), unequipPlayer 는 Player 객체 입니다.

\-- 샘플 --

```lua
local item = Script.Parent

local function UnEquipItem(Player) --UnEquipEvent에 연결된 함수는 Player 인자가 고정적으로 들어가요.

end
item.UnEquipEvent:Connect(UnEquipItem) --아이템에 장착 해제시 호출할 함수를 연결해요.
```

## **함수**

<br>

| **number GetItemCount()** |
| ------------------------- |

아이템의 개수를 얻을 수 있어요.

\-- 샘플 --

```lua
print(Item:GetItemCount())
```

<br>

| **bool IsEquiped()** |
| -------------------- |

현재 아이템 장착상태인지를 확인 할 수 있어요.

\-- 샘플 --

```lua
print(Item:IsEquiped())
```

<br>

| **number GetActionCoolTime(string ActionName)** |
| ----------------------------------------------- |

아이템에 설정한 해당 액션의 쿨타임을 얻을 수 있어요. (설정할 액션 이름)

\-- 샘플 --

```lua
print(Item:GetActionCoolTime("Fire")) -- AddAction이나 AddToggleAction 함수로 먼저 액션을 추가해준 후에 사용해요.
```

<br>

| **void SetActionCoolTime(string ActionName, number Time)** |
| ---------------------------------------------------------- |

아이템에 설정한 해당 액션의 쿨타임을 설정할 수 있어요. (설정할 액션 이름, 설정하고 싶은 시간)

\-- 샘플 --

```lua
Item:SetActionCoolTime("Fire", 3) -- AddAction이나 AddToggleAction 함수로 먼저 액션을 추가해준 후에 사용해요.
```

<br>

| **string GetEquipSlot()** |
| ------------------------- |

해당 아이템의 장착 슬롯을 가져올 수 있어요.

\-- 샘플 --

```lua
print(Item:GetEquipSlot()) -- Item 객체의 'EquipSlot' 프로퍼티를 가져와요.
```

<br>

| **number GetIconImg()** |
| ----------------------- |

\-- 샘플 --

```lua
print(Item:GetIconImg()) -- Item 객체의 'IconTextureID' 프로퍼티를 가져와요.
```

<br>

| **void AddAction(string ActionName, number ActionCoolTime, function TargetFunction)** |
| ------------------------------------------------------------------------------------- |

아이템 착용 후 액션을 추가해요. (액션 이름, 해당 액션의 쿨타임, 연결 함수)

\-- 샘플 --

```lua
--클라 스크립트에서-------------
Item = Script.Parent

local function StartClick(player, curCameraPos , curCameraForward) --AddAction에 연결된 함수는 player, curCameraPos, curCameraForward 인자가 고정적으로 들어가요.
    print("액션 시작 : 클라")
end
Item:AddAction("Fire", 0.5, false, StartClick, Enum.Key.LeftMouseButton) -- * false : 키 입력 유지 시 액션 지속 사용 여부


--서버 스크립트에서-------------
Item = Script.Parent

local function StartClick(player, curCameraPos , curCameraForward) --AddAction에 연결된 함수는 player, curCameraPos, curCameraForward 인자가 고정적으로 들어가요.
    print("액션 시작 : 서버")
end
Item:AddAction("Fire", 0.5, StartClick) -- 클라 스크립트에서 등록한 키가 입력되면 연결된 함수를 호출해요.
```

<br>

| **void AddToggleAction(string ActionName, number ActionCoolTime, function StartFunction, function EndFunction)** |
| ---------------------------------------------------------------------------------------------------------------- |

아이템 착용 후 토글 액션을 추가해요. (액션 이름, 액션 쿨타임, 액션 시작 시 연결 함수, 액션 종료 시 연결 함수)

\-- 샘플 --

```lua
--클라 스크립트에서-------------
Item = Script.Parent

local function StartClick(player, curCameraPos , curCameraForward) --AddToggleAction에 연결된 함수는 player, curCameraPos, curCameraForward 인자가 고정적으로 들어가요.
    print("액션 시작 : 클라")
end

local function EndClick(player, curCameraPos , curCameraForward) --AddToggleAction에 연결된 함수는 player, curCameraPos, curCameraForward 인자가 고정적으로 들어가요.
    print("액션 종료 : 클라")
end

Item:AddToggleAction("Fire", 0.5, StartClick, EndClick, Enum.Key.LeftMouseButton)


--서버 스크립트에서-------------
Item = Script.Parent

local function StartClick(player, curCameraPos , curCameraForward) --AddToggleAction에 연결된 함수는 player, curCameraPos, curCameraForward 인자가 고정적으로 들어가요.
    print("액션 시작 : 서버")
end

local function EndClick(player, curCameraPos , curCameraForward) --AddToggleAction에 연결된 함수는 player, curCameraPos, curCameraForward 인자가 고정적으로 들어가요.
    print("액션 종료 : 서버")
end

Item:AddToggleAction("Fire", 0.5, StartClick, EndClick) -- 클라 스크립트에서 등록한 키가 입력되면 연결된 함수를 호출해요.
```


---

# Agent Instructions: 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://ditoland-utplus.gitbook.io/ditoland/api-reference/common/item.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.
