Item
์์ดํ ์ค๋ธ์ ํธ๋ฅผ ๋ค๋ฃจ๊ธฐ ์ํ ๊ฐ์ฒด์์.
์ด๋ฒคํธ
UseEvent
์์ดํ ์ฌ์ฉ ์ ํธ์ถ๋๋ ์ด๋ฒคํธ์์. ์ฐ๊ฒฐํจ์ ํ์์ function(usePlayer), usePlayer ๋ Player ๊ฐ์ฒด ์ ๋๋ค.
-- ์ํ --
local Item = Script.Parent
local function UseItem(player) --UseEvent์ ์ฐ๊ฒฐ๋ ํจ์๋ Player ์ธ์๊ฐ ๊ณ ์ ์ ์ผ๋ก ๋ค์ด๊ฐ์.
print("Use Item")
end
Item.UseEvent:Connect(UseItem) --์์ดํ
์ฌ์ฉ์ ํธ์ถํ ํจ์๋ฅผ ์ฐ๊ฒฐํด์.
EquipEvent
์์ดํ ์ฅ์ฐฉ ์ ํธ์ถ๋๋ ์ด๋ฒคํธ์์. ์ฐ๊ฒฐํจ์ ํ์์ function(equipPlayer), equipPlayer ๋ Player ๊ฐ์ฒด ์ ๋๋ค.
-- ์ํ --
local Item = Script.Parent
local function EquipItem(player) --EquipEvent์ ์ฐ๊ฒฐ๋ ํจ์๋ player ์ธ์๊ฐ ๊ณ ์ ์ ์ผ๋ก ๋ค์ด๊ฐ์.
end
Item.EquipEvent:Connect(EquipItem) --์์ดํ
์ ์ฅ์ฐฉ์ ํธ์ถํ ํจ์๋ฅผ ์ฐ๊ฒฐํด์.
UnEquipEvent
์์ดํ ํ์ฐฉ ์ ํธ์ถ๋๋ ์ด๋ฒคํธ์์. ์ฐ๊ฒฐํจ์ ํ์์ function(unequipPlayer), unequipPlayer ๋ Player ๊ฐ์ฒด ์ ๋๋ค.
-- ์ํ --
local item = Script.Parent
local function UnEquipItem(Player) --UnEquipEvent์ ์ฐ๊ฒฐ๋ ํจ์๋ Player ์ธ์๊ฐ ๊ณ ์ ์ ์ผ๋ก ๋ค์ด๊ฐ์.
end
item.UnEquipEvent:Connect(UnEquipItem) --์์ดํ
์ ์ฅ์ฐฉ ํด์ ์ ํธ์ถํ ํจ์๋ฅผ ์ฐ๊ฒฐํด์.
ํจ์
number GetItemCount()
์์ดํ ์ ๊ฐ์๋ฅผ ์ป์ ์ ์์ด์.
-- ์ํ --
print(Item:GetItemCount())
bool IsEquiped()
ํ์ฌ ์์ดํ ์ฅ์ฐฉ์ํ์ธ์ง๋ฅผ ํ์ธ ํ ์ ์์ด์.
-- ์ํ --
print(Item:IsEquiped())
number GetActionCoolTime(string ActionName)
์์ดํ ์ ์ค์ ํ ํด๋น ์ก์ ์ ์ฟจํ์์ ์ป์ ์ ์์ด์. (์ค์ ํ ์ก์ ์ด๋ฆ)
-- ์ํ --
print(Item:GetActionCoolTime("Fire")) -- AddAction์ด๋ AddToggleAction ํจ์๋ก ๋จผ์ ์ก์
์ ์ถ๊ฐํด์ค ํ์ ์ฌ์ฉํด์.
void SetActionCoolTime(string ActionName, number Time)
์์ดํ ์ ์ค์ ํ ํด๋น ์ก์ ์ ์ฟจํ์์ ์ค์ ํ ์ ์์ด์. (์ค์ ํ ์ก์ ์ด๋ฆ, ์ค์ ํ๊ณ ์ถ์ ์๊ฐ)
-- ์ํ --
Item:SetActionCoolTime("Fire", 3) -- AddAction์ด๋ AddToggleAction ํจ์๋ก ๋จผ์ ์ก์
์ ์ถ๊ฐํด์ค ํ์ ์ฌ์ฉํด์.
string GetEquipSlot()
ํด๋น ์์ดํ ์ ์ฅ์ฐฉ ์ฌ๋กฏ์ ๊ฐ์ ธ์ฌ ์ ์์ด์.
-- ์ํ --
print(Item:GetEquipSlot()) -- Item ๊ฐ์ฒด์ 'EquipSlot' ํ๋กํผํฐ๋ฅผ ๊ฐ์ ธ์์.
number GetIconImg()
-- ์ํ --
print(Item:GetIconImg()) -- Item ๊ฐ์ฒด์ 'IconTextureID' ํ๋กํผํฐ๋ฅผ ๊ฐ์ ธ์์.
void AddAction(string ActionName, number ActionCoolTime, function TargetFunction)
์์ดํ ์ฐฉ์ฉ ํ ์ก์ ์ ์ถ๊ฐํด์. (์ก์ ์ด๋ฆ, ํด๋น ์ก์ ์ ์ฟจํ์, ์ฐ๊ฒฐ ํจ์)
-- ์ํ --
--ํด๋ผ ์คํฌ๋ฆฝํธ์์-------------
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) -- ํด๋ผ ์คํฌ๋ฆฝํธ์์ ๋ฑ๋กํ ํค๊ฐ ์
๋ ฅ๋๋ฉด ์ฐ๊ฒฐ๋ ํจ์๋ฅผ ํธ์ถํด์.
void AddToggleAction(string ActionName, number ActionCoolTime, function StartFunction, function EndFunction)
์์ดํ ์ฐฉ์ฉ ํ ํ ๊ธ ์ก์ ์ ์ถ๊ฐํด์. (์ก์ ์ด๋ฆ, ์ก์ ์ฟจํ์, ์ก์ ์์ ์ ์ฐ๊ฒฐ ํจ์, ์ก์ ์ข ๋ฃ ์ ์ฐ๊ฒฐ ํจ์)
-- ์ํ --
--ํด๋ผ ์คํฌ๋ฆฝํธ์์-------------
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) -- ํด๋ผ ์คํฌ๋ฆฝํธ์์ ๋ฑ๋กํ ํค๊ฐ ์
๋ ฅ๋๋ฉด ์ฐ๊ฒฐ๋ ํจ์๋ฅผ ํธ์ถํด์.
Last updated
Was this helpful?