Thread Tools Display Modes
04-09-11, 09:03 AM   #1
Haleth
This Space For Rent
 
Haleth's Avatar
Featured
Join Date: Sep 2008
Posts: 1,173
Need help with bags script.

So I'm using my own version of Alza's aBags. For a while I've been trying to make it automatically update when a new/bigger bag is equipped, but it requires a Reload UI first. This is because the script that reskins bags is only ran once, to save CPU:

Code:
local firstopened = 1

...

local ReanchorButtons = function()
	if(firstopened==1) then
		for f = 1, CheckSlots() do
			con = "ContainerFrame"..f
			_G[con]:EnableMouse(false)
			_G[con.."CloseButton"]:Hide()
			_G[con.."PortraitButton"]:EnableMouse(false)

			for i = 1, 7 do
				select(i, _G[con]:GetRegions()):SetAlpha(0)
			end

			for i = GetContainerNumSlots(f-1), 1, -1  do
				bu = _G[con.."Item"..i]
				bu:SetFrameStrata("HIGH")
				tinsert(buttons, bu)
				_G[con.."Item"..i.."Count"]:SetFont(C.media.font, 8, "OUTLINEMONOCHROME")
				_G[con.."Item"..i.."Count"]:ClearAllPoints()
				_G[con.."Item"..i.."Count"]:SetPoint("TOP", bu, 0, -2)
				_G[con.."Item"..i.."IconTexture"]:SetTexCoord(.1,.9,.1,.9)
				_G[con.."Item"..i.."IconQuestTexture"]:SetTexture(C.media.questborder)
				_G[con.."Item"..i.."IconQuestTexture"]:SetVertexColor(1, 0, 0)
				_G[con.."Item"..i.."IconQuestTexture"]:SetTexCoord(0.05, .955, 0.05, .965)
				_G[con.."Item"..i.."IconQuestTexture"].SetTexture = F.dummy
			end
		end
		MoveButtons(buttons, holder, GetColumns())
		firstopened = 0
	end
	holder:Show()
end

...

for i = 1, 5 do
	hooksecurefunc(_G["ContainerFrame"..i], "Show", ReanchorButtons)
	...
end
(CheckSlots is a function that returns the number of bags)

What would be a good way to make sure that it's also ran again when a new bag is equipped?
  Reply With Quote
04-23-11, 07:17 AM   #2
Aftermathhqt
A Molten Giant
 
Aftermathhqt's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 784
Found an fix saved me 200 kib on the bag addon :P

Code:
local function UpdateButtons(frame, size, id)
    local name = frame:GetName();
    for i = 1, MAX_CONTAINER_ITEMS do
        CreateBorder(_G[name.."Item"..i], 12, R, G, B, 1)
    end	
end
hooksecurefunc("ContainerFrame_GenerateFrame", UpdateButtons)
  Reply With Quote
04-23-11, 07:56 AM   #3
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
kib? What is that?
  Reply With Quote
04-23-11, 08:43 AM   #4
Lily.Petal
A Molten Giant
 
Lily.Petal's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2010
Posts: 540
Originally Posted by Duugu View Post
kib? What is that?
Think it means Kilo Byte O.o
__________________

Aggro Color to KG Panels Borders - Nibelheim
Lua Based UI Hider - Nibelheim
Custom LUA PowerText - Stuf - Nibelheim, Seerah
  Reply With Quote
04-23-11, 09:50 AM   #5
Aftermathhqt
A Molten Giant
 
Aftermathhqt's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 784
Originally Posted by Duugu View Post
kib? What is that?
Example;

Code:
kilobyte (kB) 103 210 kibibyte (KiB) 210 
megabyte (MB) 106 220 mebibyte (MiB) 220
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Need help with bags script.

Thread Tools
Display Modes

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