diff --git a/src/Item/Item.lua b/src/Item/Item.lua index df7b18c..af7571a 100644 --- a/src/Item/Item.lua +++ b/src/Item/Item.lua @@ -298,6 +298,42 @@ function Item:IsEquipped() return IsEquippedItem(self:GetID()) 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 ---@return boolean function Item:IsOnCooldown() diff --git a/src/_bastion.lua b/src/_bastion.lua index 72070ea..d1ac5c2 100644 --- a/src/_bastion.lua +++ b/src/_bastion.lua @@ -189,6 +189,20 @@ for i = 1, #bastionFiles do Bastion:Require(bastionFiles[i]) 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() return UnitAffectingCombat("player") end)