Originally Posted by Phanx
That seems... incredibly overcomplicated. Nothing in the character frame is ever "protected" (that's only for the in-game store UI) and texture objects are never secure, so you can freely manipulate them in combat without any danger. Assuming the frame name and texture path in your code are correct, all you should need is this:
Code:
local setting
hooksecurefunc(CharacterBackSlotIconTexture, "SetTexture", function(self, texture)
if not setting and string.find(texture, "PaperDoll") then
setting = true
self:SetTexture("Interface\\PaperDoll\\UI-PaperDoll-Slot-SecondaryHand")
setting = nil
end
end)
|
The only reason i wrote it like that, so i could use this LockTexture in the future in other frames. I'm not sure about textures cannot be protected or not, since you could use a simple texture as a button, and also has SetPoint and ClearAllPoint methods, i just went with the safe method, but you could be right. The issue with your code, the game using the same texture for empty and equipped slots, so you need to add this:
Lua Code:
local setting
hooksecurefunc(CharacterBackSlotIconTexture, "SetTexture", function(self, texture)
if not setting and string.find(texture, "PaperDoll") then
setting = true
local id = GetInventoryItemID("player", GetInventorySlotInfo("BackSlot"))
if id then
local texture = GetInventoryItemTexture("player", GetInventorySlotInfo("BackSlot"))
self:SetTexture(texture)
else
local texture = "Interface\\PaperDoll\\UI-PaperDoll-Slot-SecondaryHand"
self:SetTexture(texture)
end
setting = nil
end
end)