Thread Tools Display Modes
07-03-10, 08:05 AM   #1
hairy_palms
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Feb 2010
Posts: 25
Bag Lua Problem

ive written an addon to try and open/close my bags when i go to the AH or mail or vendor, so far it works 50%, the bags open perfectly, but they dont close when i leave the vendor/AH, can anyone see where ive gone wrong?

Code:
--------------
--Opening
--------------
local opensackframe = CreateFrame("FRAME", "openmysack");

opensackframe:RegisterEvent("AUCTION_HOUSE_SHOW")
opensackframe:RegisterEvent("BANKFRAME_OPENED")
opensackframe:RegisterEvent("GUILDBANKFRAME_OPENED")
opensackframe:RegisterEvent("MAIL_SHOW")
opensackframe:RegisterEvent("MERCHANT_SHOW")
opensackframe:RegisterEvent("TRADE_SHOW")

local function openeventHandler(self, event, ...)
	OpenAllBags(true)
end
opensackframe:SetScript("OnEvent", openeventHandler);

--------------
--Closing
--------------

local closesackframe = CreateFrame("FRAME2", "closemysack");

closesackframe:RegisterEvent("AUCTION_HOUSE_CLOSED")
closesackframe:RegisterEvent("BANKFRAME_CLOSED")
closesackframe:RegisterEvent("GUILDBANKFRAME_CLOSED")
closesackframe:RegisterEvent("MAIL_CLOSED")
closesackframe:RegisterEvent("MERCHANT_CLOSED")
closesackframe:RegisterEvent("TRADE_CLOSE")

local function closeeventHandler(self, event, ...)
	CloseAllBags()
end
closesackframe:SetScript("OnEvent", closeeventHandler);
the CloseAllBags() never seems to get called.

Last edited by hairy_palms : 07-03-10 at 08:20 AM.
  Reply With Quote
07-03-10, 08:49 AM   #2
xConStruct
A Chromatic Dragonspawn
 
xConStruct's Avatar
AddOn Author - Click to view addons
Join Date: May 2008
Posts: 199
Code:
local closesackframe = CreateFrame("FRAME2", "closemysack");
"FRAME2" is not a valid widget type. You meant "Frame" here.
__________________
« Website | GitHub »

Oh hai!
  Reply With Quote
07-03-10, 09:05 AM   #3
hairy_palms
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Feb 2010
Posts: 25
ah thanks a bunch knew i'd done something silly
  Reply With Quote
07-04-10, 10:13 AM   #4
hairy_palms
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Feb 2010
Posts: 25
hopefully my next mistake is just as obvious

im trying to hide the backgrounds of the default backpacks, running the commands individually ingame as /script works fine, i thought i might be missing an event, but after 2 hrs browsing API documentation i cant see any events im missing. [EDIT]hmm it seems the BAG_OPEN isnt fireing it works on BAG_UPDATE.

Code:
------------
--Hide Bag Backgrounds
------------

local hiding = CreateFrame("Frame", "stealthbagz");
hiding:RegisterEvent("PLAYER_ENTERING_WORLD")
hiding:RegisterEvent("BAG_UPDATE")
hiding:RegisterEvent("BAG_OPEN")

local function hideBG(self, event, ...)
	for i = 1, NUM_CONTAINER_FRAMES do
		_G["ContainerFrame"..i.."CloseButton"]:Hide() -- works fine
		_G["ContainerFrame"..i.."BackgroundTop"]:Hide()
		_G["ContainerFrame"..i.."BackgroundBottom"]:Hide()
		_G["ContainerFrame"..i.."BackgroundMiddle1"]:Hide()
	end
end

hiding:SetScript("OnEvent", hideBG);

Last edited by hairy_palms : 07-04-10 at 10:38 AM.
  Reply With Quote
07-04-10, 10:52 AM   #5
hairy_palms
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Feb 2010
Posts: 25
ah i was making it harder than needed, didnt realise BAG_OPEN was deprecated, all i needed was

Code:
local function hideBG()
	ContainerFrame1MoneyFrame:Hide()
	for i = 1, NUM_CONTAINER_FRAMES do
		_G["ContainerFrame"..i.."CloseButton"]:Hide()
		_G["ContainerFrame"..i.."BackgroundTop"]:Hide()
		_G["ContainerFrame"..i.."BackgroundBottom"]:Hide()
		_G["ContainerFrame"..i.."BackgroundMiddle1"]:Hide()
	end
end
hooksecurefunc("ContainerFrame_OnShow", function() hideBG() end)
  Reply With Quote
07-04-10, 04:36 PM   #6
hairy_palms
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Feb 2010
Posts: 25
last problem i promise, im trying to anchor frames to open bags as i create them.
if i set it explicitly to ContainerFrame1 then it works,
but then all the frames are anchored to the same bag i want to anchor each frame to its respective bag, anyone see where ive gone wrong?

Code:
for i = 1, NUM_CONTAINER_FRAMES do
	local contname = "ContainerFrame"..i
	local bagbg = CreateFrame("Frame", bagbg, contname)--ContainerFrame1)--this is the problem
	bagbg:SetPoint("TOPRIGHT", contname, "TOPRIGHT", -5, -2)
	bagbg:SetPoint("BOTTOMLEFT", contname, "BOTTOMLEFT", 5, 0)	
	bagbg:SetBackdrop( { 
	  bgFile = BLANK_TEXTURE, 
	  edgeFile = BLANK_TEXTURE, 
	  tile = false, tileSize = 0, edgeSize = 1, 
	  insets = { left = -1, right = -1, top = -1, bottom = -1 }
	})
	bagbg:SetBackdropColor( 0.3,0.3,0.3,0.8)
end
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Bag Lua Problem


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off