[AddOn] API Region IsVisible

[AddOn] API Region IsVisible

by rdrmdr » Wed Apr 06, 2016 6:55 pm

Hi, I have some code where I have an
Code: Select all
if (ContainerFrame1:IsVisible()) then
but I have a variable with the number of the container (1 to 5) and I wanted to know how can I make something like...
Code: Select all
if ("ContainerFrame"..variable..":IsVisible()") then
because that doesn't work and I searched about the API and it doesn't say I can use strings. Any way possible?
rdrmdr
Grunt
Grunt
 

Re: [AddOn] API Region IsVisible

by EinBaum » Wed Apr 06, 2016 7:31 pm

Code: Select all
if (getglobal("ContainerFrame"..variable):IsVisible()) then

http://wowwiki.wikia.com/wiki/API_getglobal

no problem
User avatar
EinBaum
Sergeant
Sergeant
 

Re: [AddOn] API Region IsVisible

by rdrmdr » Wed Apr 06, 2016 7:37 pm

I had readed about that but I didn't knowed it could be used that way.Thank you so much! :D
rdrmdr
Grunt
Grunt
 

Re: [AddOn] API Region IsVisible

by rdrmdr » Wed Apr 06, 2016 8:11 pm

YES! I finally got the code to work, all of it! :o :mrgreen:
If anyone wanna take a look...(the part where it prints stuff on the chat is where I'm gonna add code in the future)
Code: Select all
local AddOn=0
local AddOnBag=0
local AddOnSlot=1
GameTooltip:SetScript("OnShow",function()
if (string.gsub(string.gsub(GetMouseFocus():GetName(),"ContainerFrame%d",""),"%d","")=="Item" and AddOn==0)then
AddOn=1
AddOnBag=string.gsub(string.gsub(GetMouseFocus():GetName(),"ContainerFrame",""),"Item%d+","")-1
AddOnSlot=GetContainerNumSlots(AddOnBag)-string.gsub(GetMouseFocus():GetName(),"ContainerFrame%dItem","")+1
DEFAULT_CHAT_FRAME:AddMessage("In"..GetContainerItemLink(AddOnBag, AddOnSlot))
end
end)
GameTooltip:SetScript("OnHide",function()
if (AddOn==1 and getglobal("ContainerFrame"..(AddOnBag+1)):IsVisible())then
if (GetMouseFocus():GetName()~="ContainerFrame"..(AddOnBag+1).."Item"..(-AddOnSlot+1+GetContainerNumSlots(AddOnBag)))then
AddOn=0
DEFAULT_CHAT_FRAME:AddMessage("OutOn"..GetContainerItemLink(AddOnBag, AddOnSlot))
end
end
end)
AddOnFrame=CreateFrame("Frame")
AddOnFrame:SetScript("OnUpdate",function()
local AddOnFrame=GetMouseFocus()
if AddOnFrame then
local AddOnName=AddOnFrame:GetName()or tostring(AddOnFrame)
end
if (AddOn==1 and not AddOnFrame)then
AddOn=0
DEFAULT_CHAT_FRAME:AddMessage("OutUp"..GetContainerItemLink(AddOnBag, AddOnSlot))
end
end)
I wanna say, thank you:
wowprogramming.com
google.com
stackoverflow.com
wowwiki.wikia.com
vanilla-wow.wikia.com

and other sites that I don't have openned right now :lol: like...
townlong-yak.com/framexml/1.1.2
github.com/Gethe
youtube.com/user/Infernoxv8
rdrmdr
Grunt
Grunt
 


Return to Addons & macros