Help on lua code error

I made this simple lua code to print on screen the link of the item that my mouse is over when the code runs:
So I need to add an if statment here:
I can't see if the mouse is over an item (with the bag opened) and I can't figure if the bag is nil (GetMouseFocus():GetParent():GetID()). Someone help me please, it must be something easy.
P.S.: It's almost identicall to the blizzard code but only actives when I press shift, not shift+left click (because I coldn't figure it out
). You can see it here https://www.townlong-yak.com/framexml/1.1.2/ContainerFrame.lua#413
- Code: Select all
TestFrame=CreateFrame("Frame")
TestFrame:SetScript("OnUpdate",function()
if (IsShiftKeyDown())then
ChatFrame1:Clear()
DEFAULT_CHAT_FRAME:AddMessage(GetContainerItemLink(GetMouseFocus():GetParent():GetID(), GetMouseFocus():GetID()))
end
end)
So I need to add an if statment here:
- Code: Select all
TestFrame=CreateFrame("Frame")
TestFrame:SetScript("OnUpdate",function()
if (IsShiftKeyDown())then
if (GetMouseFocus():GetParent():GetID()==nil)then
ChatFrame1:Clear()
DEFAULT_CHAT_FRAME:AddMessage(GetContainerItemLink(GetMouseFocus():GetParent():GetID(), GetMouseFocus():GetID()))
end
end
end)
I can't see if the mouse is over an item (with the bag opened) and I can't figure if the bag is nil (GetMouseFocus():GetParent():GetID()). Someone help me please, it must be something easy.
P.S.: It's almost identicall to the blizzard code but only actives when I press shift, not shift+left click (because I coldn't figure it out
