Add Item:GetEquippedSlot

main
ck 11 months ago
parent 4e697fa0a2
commit f43b18f311
  1. 36
      src/Item/Item.lua
  2. 14
      src/_bastion.lua

@ -298,6 +298,42 @@ function Item:IsEquipped()
return IsEquippedItem(self:GetID()) return IsEquippedItem(self:GetID())
end end
function Item:GetEquippedSlot()
if not self:IsEquippable() and not self:IsEquipped() then
return false
end
local itemId = self:GetID()
local slots = {
[1] = INVSLOT_AMMO,
[2] = INVSLOT_HEAD,
[3] = INVSLOT_NECK,
[4] = INVSLOT_SHOULDER,
[5] = INVSLOT_BODY,
[6] = INVSLOT_CHEST,
[7] = INVSLOT_WAIST,
[8] = INVSLOT_LEGS,
[9] = INVSLOT_FEET,
[10] = INVSLOT_WRIST,
[11] = INVSLOT_HAND,
[12] = INVSLOT_FINGER1,
[13] = INVSLOT_FINGER2,
[14] = INVSLOT_TRINKET1,
[15] = INVSLOT_TRINKET2,
[16] = INVSLOT_BACK,
[17] = INVSLOT_MAINHAND,
[18] = INVSLOT_OFFHAND,
[19] = INVSLOT_RANGED,
[20] = INVSLOT_TABARD,
}
for i = 1, #slots do
local slot = slots[i]
if GetInventoryItemID("player", slot) == itemId then
return slot
end
end
return false
end
-- Check if the Item is on cooldown -- Check if the Item is on cooldown
---@return boolean ---@return boolean
function Item:IsOnCooldown() function Item:IsOnCooldown()

@ -189,6 +189,20 @@ for i = 1, #bastionFiles do
Bastion:Require(bastionFiles[i]) Bastion:Require(bastionFiles[i])
end end
---@param toggle? boolean
function Bastion:Toggle(toggle)
Bastion.Enabled = type(toggle) ~= "nil" and toggle or not Bastion.Enabled
end
Bastion.Globals.Command:Register('toggle', 'Toggle bastion on/off', function()
Bastion:Toggle()
if Bastion.Enabled then
Bastion.Util:Print("Enabled")
else
Bastion.Util:Print("Disabled")
end
end)
Bastion.Globals.CombatTimer = Bastion.Timer:New("combat", function() Bastion.Globals.CombatTimer = Bastion.Timer:New("combat", function()
return UnitAffectingCombat("player") return UnitAffectingCombat("player")
end) end)

Loading…
Cancel
Save