Skip to content

Commit

Permalink
Add /tc save command to prevent restoring currently equipped telepo…
Browse files Browse the repository at this point in the history
…rt items after they are used

Closes #1
  • Loading branch information
jordonwow committed May 14, 2024
1 parent 40c05fd commit 491c5b0
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 12 deletions.
40 changes: 28 additions & 12 deletions Core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@ function TeleportCloak:Print(...)
print("|cff33ff99TeleportCloak:|r ", ...)
end

local InventorySlots = {
INVSLOT_NECK,
INVSLOT_FEET,
INVSLOT_FINGER1,
INVSLOT_FINGER2,
INVSLOT_TRINKET1,
INVSLOT_TRINKET2,
INVSLOT_BACK,
INVSLOT_TABARD,
}

local InventoryTypes = {
cloaks = INVTYPE_CLOAK,
feet = INVTYPE_FEET,
Expand Down Expand Up @@ -45,6 +56,21 @@ function TeleportCloak:Command(msg)
end
end
return
elseif cmd == "save" then
local count = 0
for _, slot in pairs(InventorySlots) do
local itemId = GetInventoryItemID("player", slot)
if itemId and self:IsTeleportItem(itemId) then
self.db.saved[slot] = itemId
self:Print(select(2, GetItemInfo(itemId)), "saved.")
count = count + 1
end
end
if count == 0 then
self:Print("No teleport items equipped.")
end
return

elseif cmd == "warnings" then
self.db.warnings = not self.db.warnings
else
Expand All @@ -61,7 +87,8 @@ function TeleportCloak:Command(msg)
types = types.." |cff80ffc0"..inventoryType.."|r,"
end
self:Print(types, "and will add all items of that type.")

self:Print("To prevent TeleportCloak from restoring currently equipped teleport items after they are used,",
"type |cff80ffc0/tc save|r.")
end
self:Print("Warnings are",
self.db.warnings and "|cff19ff19Enabled|r." or "|cffff2020Disabled|r.",
Expand All @@ -81,17 +108,6 @@ function TeleportCloak:IsTeleportItem(item)
return false
end

local InventorySlots = {
INVSLOT_NECK,
INVSLOT_FEET,
INVSLOT_FINGER1,
INVSLOT_FINGER2,
INVSLOT_TRINKET1,
INVSLOT_TRINKET2,
INVSLOT_BACK,
INVSLOT_TABARD,
}

TeleportCloak:SetScript("OnEvent", function(self, event, ...)
if event == "ADDON_LOADED" then
local addon = ...
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ You can also `/tc add <type>` to limit the macro to a specific type. Valid types

Items added with `/tc add` will be reset after each click.

## Prevent Restoration

To prevent TeleportCloak from restoring currently equipped teleport items after they are used, type `/tc save`

## Contributors
* [peterwooley](https://github.com/peterwooley)
* Kanegasi
Expand Down

0 comments on commit 491c5b0

Please sign in to comment.