Thread Tools Display Modes
10-07-10, 03:08 PM   #1
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
SetPoint when i = 1,40

okay so heres what im doing.. trying to resetpoint bliz buffs into two different box's. So far so good until it came to more then 1 buff per box. The problem is it always setpoints on top of each other. How do i get it to setpoint accordingly with the use of a variable? I could of course make this all work by listing out individual code for all 40 buffs/debuffs but that wouldnt look or run well would it...

Code:
function addon:TargetBuffSetup()
    for i = 1,40 do 
        local bufname, bufrank, bufico, bufcount, bufType, buftottime, bufexpirTime, bufCaster, bufStealable,_, bufspellId = UnitBuff("target", i)
        
        if bufname ~= nil and bufCaster == "player" then 
            
            TargetFrameBuff1:SetParent(TargetIBuffedFrame)
            TargetFrameBuff1:ClearAllPoints()
            TargetFrameBuff1:SetPoint("TOPLEFT", TargetIBuffedFrame, "TOPLEFT", 0, 0)
            
            _G["TargetFrameBuff" .. i]:SetParent(TargetIBuffedFrame)
            _G["TargetFrameBuff" .. i]:ClearAllPoints()
            _G["TargetFrameBuff" .. i]:SetPoint("LEFT", _G["TargetFrameBuff" .. i], "RIGHT", 0, 0)
        
        
        elseif bufname ~= nil and bufCaster ~= "player" then
            
            TargetFrameBuff1:SetParent(TargetBuffedFrame)
            TargetFrameBuff1:ClearAllPoints()
            TargetFrameBuff1:SetPoint("TOPLEFT", TargetBuffedFrame, "TOPLEFT", 0, 0)
            
            _G["TargetFrameBuff" .. i]:SetParent(TargetBuffedFrame)
            _G["TargetFrameBuff" .. i]:ClearAllPoints()
            _G["TargetFrameBuff" .. i]:SetPoint("LEFT", _G["TargetFrameBuff" .. i], "RIGHT", 0, 0)
        end
    end 
end
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
10-07-10, 03:10 PM   #2
Ailae
A Rage Talon Dragon Guard
 
Ailae's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2007
Posts: 318
You are anchoring it to itself.

_G["TargetFrameBuff" .. i] is :SetPoint to _G["TargetFrameBuff" .. i]
__________________
Oh, the simulated horror!
  Reply With Quote
10-07-10, 03:19 PM   #3
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
yea, thats what my question is though. when using i like that how or is it even possible to make the first frame it pulls anchor where it should then anchor all the other "i"'s to the first one?
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
10-07-10, 03:21 PM   #4
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
the first setpoint should be...
G["TargetFrameBuff" .. i]:SetPoint("TOPLEFT", TargetIBuffedFrame, "TOPLEFT", 0, 0)

but after it sets the first buff to that location how do i make it set the rest of the buffs off of that one? without listing out all of the buff frame numbers by hand?

this is the chunk i ment to post.. this works but they anchor on top of each other.

Code:
function addon:TargetBuffSetup()
    for i = 1,40 do 
        local bufname, bufrank, bufico, bufcount, bufType, buftottime, bufexpirTime, bufCaster, bufStealable,_, bufspellId = UnitBuff("target", i)
        
        if bufname ~= nil and bufCaster == "player" then 

            _G["TargetFrameBuff" .. i]:SetParent(TargetIBuffedFrame)
            _G["TargetFrameBuff" .. i]:ClearAllPoints()
            _G["TargetFrameBuff" .. i]:SetPoint("TOPLEFT", TargetIBuffedFrame, "TOPLEFT", 0, 0)
        
        elseif bufname ~= nil and bufCaster ~= "player" then

            _G["TargetFrameBuff" .. i]:SetParent(TargetBuffedFrame)
            _G["TargetFrameBuff" .. i]:ClearAllPoints()
            _G["TargetFrameBuff" .. i]:SetPoint("TOPLEFT", TargetBuffedFrame, "TOPLEFT", 0, 0)

        end
    end 
end
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
10-07-10, 04:48 PM   #5
Ailae
A Rage Talon Dragon Guard
 
Ailae's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2007
Posts: 318
Drycoded, but so you get the general idea.

Code:
if i == 1 then -- first row
        _G["TargetFrameBuff" .. i]:SetPoint("TOPLEFT", TargetIBuffedFrame, "TOPLEFT", 0, 0)
else
        _G["TargetFrameBuff" .. i]:SetPoint("LEFT",  _G["TargetFrameBuff" .. i-1], "RIGHT", 0, 0)
end
Essentially if i is 1, we know it's the first buff. After that we just anchor our current buff (i) to the one before (i-1).
__________________
Oh, the simulated horror!
  Reply With Quote
10-07-10, 04:56 PM   #6
Vrul
A Scalebane Royal Guard
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 404
This is one way to go:
Code:
function addon:TargetBuffSetup()
	local buff, prevMyBuff, prevOtherBuff
	for index = 1, 40 do 
		if UnitBuff('target', index) then
			buff = _G['TargetFrameBuff' .. index]
			buff:ClearAllPoints()
			if buffCaster ~= 'player' then 
				buff:SetParent(TargetBuffedFrame)
				if prevOtherBuff then
					buff:SetPoint('LEFT', prevOtherBuff, 'RIGHT')
				else
					buff:SetPoint('TOPLEFT', TargetBuffedFrame, 'TOPLEFT')
				end
				prevOtherBuff = buff
			else
				buff:SetParent(TargetIBuffedFrame)
				if prevSelfBuff then
					buff:SetPoint('LEFT', prevMyBuff, 'RIGHT')
				else
					buff:SetPoint('TOPLEFT', TargetIBuffedFrame, 'TOPLEFT')
				end
				prevMyBuff = buff
			end
		else
			break
		end
	end 
end
Not sure if you want to continue along these lines though seeing how buffs are secure in 4.0 so SetParent and SetPoint will cause errors in combat.

Last edited by Vrul : 10-07-10 at 05:04 PM.
  Reply With Quote
10-07-10, 05:02 PM   #7
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
even if i did that the problem would come when it tried to differentiate between anchoring if i == 1 but goes into the lower buff frame and then the upper buff frame's first anchor frame is not i. in other words if buff 1 goes up top and buff 2 goes down below and buff 3 or 4 goes to where buff 2 when then blah blah now im confused just trying to write it out

I think i have an idea ill be back in a bit

Vrul - they are? when doing the setpoints on them in cata beta i dont get any combat errors of course ive turned off all taint logging but... it seems to work just fine on the beta server. And if they are secure then i would need to use secure code then to move them around or are we just sol on adjusting buffs? obviously im attempting to add a buff frame to the GrimUI target frame.

and actually the most ideal way for all of this would be to write some kind of lua function and/or template to handle buffs all on its own and forget about moving around the blizz buffs.. which im poking at but... so far its like poking a dead animal... not much is happening.
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]

Last edited by Grimsin : 10-07-10 at 05:08 PM.
  Reply With Quote
10-07-10, 05:44 PM   #8
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
Vrul's way always = the best way. So with a few changes i got the code you posted to work, but now let me throw another wrench in there lol so if x number of buffs appear on something how to make it start a new row

this is the working chunk
Code:
function addon:TargetBuffSetup()
    local buff, prevMyBuff, prevOtherBuff
    for index = 1, 40 do 
        if UnitBuff('target', index) then
            buff = _G['TargetFrameBuff' .. index]
            buff:ClearAllPoints()
            buff:SetScale(1.35)
            local _,_,_,_,_,_,_, buffCaster,_,_,_ = UnitBuff("target", index);
            if buffCaster ~= 'player' then 
                buff:SetParent(TargetBuffedFrame)
                if prevOtherBuff then
                    buff:SetPoint('LEFT', prevOtherBuff, 'RIGHT')
                else
                    buff:SetPoint('TOPLEFT', TargetBuffedFrame, 'TOPLEFT')
                end
                prevOtherBuff = buff
            else
                buff:SetParent(TargetIBuffedFrame)
                if prevMyBuff then
                    buff:SetPoint('LEFT', prevMyBuff, 'RIGHT')
                else
                    buff:SetPoint('TOPLEFT', TargetIBuffedFrame, 'TOPLEFT')
                end
                prevMyBuff = buff
            end
        else
            break
        end
    end 
end
would a line like.... if index > 10 then myframe:SetPoint(blahblah) work? and of course matching if index < 10 then do blah blah?
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]

Last edited by Grimsin : 10-07-10 at 06:15 PM.
  Reply With Quote
10-07-10, 07:11 PM   #9
Vrul
A Scalebane Royal Guard
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 404
Originally Posted by Grimsin View Post
would a line like.... if index > 10 then myframe:SetPoint(blahblah) work? and of course matching if index < 10 then do blah blah?
No it would be more like:
Code:
function addon:TargetBuffSetup()
	local buff, buffCaster, buffName, _
	local myBuffsCount, myBuffsPrev, myBuffsPrevRow = 0
	local otherBuffsCount, otherBuffsPrev, otherBuffsPrevRow = 0
	for index = 1, 40 do
		buffName, _, _, _, _, _, _, buffCaster = UnitBuff('target', index)
		if buffName then
			buff = _G['TargetFrameBuff' .. index]
			buff:SetScale(1.35)
			buff:ClearAllPoints()
			if buffCaster ~= 'player' then
				buff:SetParent(TargetBuffedFrame)
				if otherBuffsCount % 10 ~= 0 then
					buff:SetPoint('LEFT', otherBuffsPrev, 'RIGHT')
				else
					if otherBuffsPrevRow then
						buff:SetPoint('TOP', otherBuffsPrevRow, 'BOTTOM')
					else
						buff:SetPoint('TOPLEFT')
					end
					otherBuffsPrevRow = buff
				end
				otherBuffsCount, otherBuffsPrev = otherBuffsCount + 1, buff
			else
				buff:SetParent(TargetIBuffedFrame)
				if myBuffsCount % 10 ~= 0 then
					buff:SetPoint('LEFT', myBuffsPrev, 'RIGHT')
				else
					if myBuffsPrevRow then
						buff:SetPoint('TOP', myBuffsPrevRow, 'BOTTOM')
					else
						buff:SetPoint('TOPLEFT')
					end
					myBuffsPrevRow = buff
				end
				myBuffsCount, myBuffsPrev = myBuffsCount + 1, buff
			end
		else
			break
		end
	end
end
  Reply With Quote
10-08-10, 11:05 AM   #10
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
So everything works fine but sometimes it fires an error, granted it still keeps working. I think that the error has to do with it trying to do math on "buff" at certain points like right before it actually has the buff information available. It happens when there is no buff cast by others in the others buff frame and then one gets cast. Most likely does it for debuffs as well. It still works as intended though, not sure what its issue is.

oh and ignore all the frame creates they are being removed once i get the layout finalized.
Code:
-- some stuff for target buffs/debuffs 


local TargetBuffMainFrame = CreateFrame('Frame', "TargetBuffMainFrame", GrimTargetFrame)
TargetBuffMainFrame:RegisterEvent("PLAYER_TARGET_CHANGED")
TargetBuffMainFrame:RegisterEvent("UNIT_AURA", "target")
TargetBuffMainFrame:SetHeight(125)
TargetBuffMainFrame:SetWidth(410)
TargetBuffMainFrame:SetPoint("BOTTOM", GrimTargetFrame, "TOP")

local TargetIBuffedFrame = CreateFrame('Frame', "TargetIBuffedFrame", GrimTargetFrame)
TargetIBuffedFrame:SetHeight(40)
TargetIBuffedFrame:SetWidth(200)
TargetIBuffedFrame:SetPoint("TOPLEFT", TargetBuffMainFrame, "TOPLEFT")
local tibbg = TargetIBuffedFrame:CreateTexture(nil, "BACKGROUND")
tibbg:SetTexture(0, 0, 0, .7)
tibbg:SetAllPoints(TargetIBuffedFrame)


local TargetIDebuffedFrame = CreateFrame('Frame', "TargetIDebuffedFrame", TargetBuffMainFrame)
TargetIDebuffedFrame:SetHeight(40)
TargetIDebuffedFrame:SetWidth(200)
TargetIDebuffedFrame:SetPoint("TOPRIGHT", TargetBuffMainFrame, "TOPRIGHT")
local tidbbg = TargetIDebuffedFrame:CreateTexture(nil, "BACKGROUND")
tidbbg:SetTexture(0, 0, 0, .7)
tidbbg:SetAllPoints(TargetIDebuffedFrame)



local TargetBuffedFrame = CreateFrame('Frame', "TargetBuffedFrame", TargetBuffMainFrame)
TargetBuffedFrame:SetHeight(80)
TargetBuffedFrame:SetWidth(200)
TargetBuffedFrame:SetPoint("BOTTOMLEFT", TargetBuffMainFrame, "BOTTOMLEFT")
local tbbg = TargetBuffedFrame:CreateTexture(nil, "BACKGROUND")
tbbg:SetTexture(0, 0, 0, .7)
tbbg:SetAllPoints(TargetBuffedFrame)



local TargetDebuffedFrame = CreateFrame('Frame', "TargetDebuffedFrame", TargetBuffMainFrame)
TargetDebuffedFrame:SetHeight(80)
TargetDebuffedFrame:SetWidth(200)
TargetDebuffedFrame:SetPoint("BOTTOMRIGHT", TargetBuffMainFrame, "BOTTOMRIGHT")
local tdbbg = TargetDebuffedFrame:CreateTexture(nil, "BACKGROUND")
tdbbg:SetTexture(0, 0, 0, .7)
tdbbg:SetAllPoints(TargetDebuffedFrame)

function addon:TargetBuffSetup()
	local buff, buffCaster, buffName, _
	local myBuffsCount, myBuffsPrev, myBuffsPrevRow = 0
	local otherBuffsCount, otherBuffsPrev, otherBuffsPrevRow = 0
	for index = 1, 40 do
		buffName, _, _, _, _, _, _, buffCaster = UnitBuff('target', index)
		if buffName then
			buff = _G['TargetFrameBuff' .. index]
			buff:ClearAllPoints()
			if buffCaster ~= 'player' then
				buff:SetParent(TargetBuffedFrame)
				buff:SetScale(1)
				if otherBuffsCount % 10 ~= 0 then
					buff:SetPoint('LEFT', otherBuffsPrev, 'RIGHT', 1, 0)
				else
					if otherBuffsPrevRow then
						buff:SetPoint('TOP', otherBuffsPrevRow, 'BOTTOM')
					else
						buff:SetPoint('TOPLEFT')
					end
					otherBuffsPrevRow = buff
				end
				otherBuffsCount, otherBuffsPrev = otherBuffsCount + 1, buff
			else
				buff:SetParent(TargetIBuffedFrame)
				buff:SetScale(1.35)
				if myBuffsCount % 10 ~= 0 then
					buff:SetPoint('LEFT', myBuffsPrev, 'RIGHT', 1, 0)
				else
					if myBuffsPrevRow then
						buff:SetPoint('TOP', myBuffsPrevRow, 'BOTTOM')
					else
						buff:SetPoint('TOPLEFT')
					end
					myBuffsPrevRow = buff
				end
				myBuffsCount, myBuffsPrev = myBuffsCount + 1, buff
			end
		else
			break
		end
	end
end

function addon:TargetDebuffSetup()
	local debuff, debuffCaster, debuffName, _
	local mydeBuffsCount, mydeBuffsPrev, mydeBuffsPrevRow = 0
	local otherdeBuffsCount, otherdeBuffsPrev, otherdeBuffsPrevRow = 0
	for index = 1, 40 do
		debuffName, _, _, _, _, _, _, debuffCaster = UnitDebuff('target', index)
		if debuffName then
			debuff = _G['TargetFrameDebuff' .. index]
			debuff:ClearAllPoints()
			if debuffCaster ~= 'player' then
				debuff:SetParent(TargetDebuffedFrame)
				debuff:SetScale(1)
				if otherdeBuffsCount % 10 ~= 0 then
					debuff:SetPoint('LEFT', otherdeBuffsPrev, 'RIGHT', 1, 0)
				else
					if otherdeBuffsPrevRow then
						debuff:SetPoint('TOP', otherdeBuffsPrevRow, 'BOTTOM')
					else
						debuff:SetPoint('TOPLEFT')
					end
					otherdeBuffsPrevRow = debuff
				end
				otherdeBuffsCount, otherdeBuffsPrev = otherdeBuffsCount + 1, debuff
			else
				debuff:SetParent(TargetIDebuffedFrame)
				debuff:SetScale(1.15)
				if mydeBuffsCount % 10 ~= 0 then
					debuff:SetPoint('LEFT', mydeBuffsPrev, 'RIGHT', 1, 0)
				else
					if mydeBuffsPrevRow then
						debuff:SetPoint('TOP', mydeBuffsPrevRow, 'BOTTOM')
					else
						debuff:SetPoint('TOPLEFT')
					end
					mydeBuffsPrevRow = debuff
				end
				mydeBuffsCount, mydeBuffsPrev = mydeBuffsCount + 1, debuff
			end
		else
			break
		end
	end
end

TargetBuffMainFrame:SetScript("OnEvent", function(self)
	
	addon:TargetBuffSetup()
	addon:TargetDebuffSetup()

end)
this is the error i get back from bugggrabber

Code:
["message"] = {
				"GrimUI-4.0.01\\TargetFrame.lua:753: attempt to index local 'buff' (a nil value)\nGrimUI-4.0.01\\TargetFrame.lua:835: in function <Interface\\AddOns\\GrimUI\\TargetFrame.lua:833>\n\nLocals:|r\nself = TargetBuffMainFrame {\n 0 = <userdata>\n}\naddon = <table> {\n DoNothing = <function> defined @Interface\\AddOns\\GrimUI\\Core.lua:5\n UnregisterAllEvents = <function> defined @Interface\\AddOns\\GrimUI\\Core.lua:53\n ResetPlayerFrame = <function> defined @Interface\\AddOns\\GrimUI\\PlayerFrame.lua:137\n skin = <unnamed> {\n }\n settings = <table> {\n }\n MicroButtonsPreCatVer = <function> defined @Interface\\AddOns\\GrimUI\\Features.lua:106\n ConfigurePlayerFrame = <function> defined @Interface\\AddOns\\GrimUI\\PlayerFrame.lua:81\n MicroButtonsCatVer = <function> defined @Interface\\AddOns\\GrimUI\\Features.lua:84\n ToggleTaintLog = <function> defined @Interface\\AddOns\\GrimUI\\GDevTools.lua:81\n ConfigureBlizPartyFrames = <function> defined @Interface\\AddOns\\GrimUI\\PartyFrames.lua:330\n LockFrame = <function> def", -- [1]
				"ined @Interface\\AddOns\\GrimUI\\Core.lua:160\n ShowDevBar = <function> defined @Interface\\AddOns\\GrimUI\\GDevTools.lua:64\n eliteRareEvent = <unnamed> {\n }\n PlayerFrameRESetScale = <function> defined @Interface\\AddOns\\GrimUI\\PlayerFrame.lua:30\n HideFrame = <function> defined @Interface\\AddOns\\GrimUI\\Core.lua:140\n ConfigureBlizTargetFrame = <function> defined @Interface\\AddOns\\GrimUI\\TargetFrame.lua:11\n ResetChatFrames = <function> defined @Interface\\AddOns\\GrimUI\\ChatFrames.lua:311\n RegisterDefaultSetting = <function> defined @Interface\\AddOns\\GrimUI\\Settings.lua:10\n CompareBuild = <function> defined @Interface\\AddOns\\GrimUI\\Core.lua:198\n itemSlots = <table> {\n }\n ShowFrame = <function> defined @Interface\\AddOns\\GrimUI\\Core.lua:150\n PlayerFrameSetScale = <function> defined @Interface\\AddOns\\GrimUI\\PlayerFrame.lua:26\n GrimUIMemUse = <function> defined @Interface\\AddOns\\GrimUI\\GDevTools.lua:25\n ConfigureSkin = <function> defined @Interface\\AddOns\\GrimUI\\Skins.lua:56\n Style", -- [2]
				"PartyFrames = <function> defined @Interface\\AddOns\\GrimUI\\StylePartyFrames.lua:215\n AdjustWatchFrameHeight = <function> defined @Interface\\AddOns\\GrimUI\\MiniMap.lua:107\n ConfigureExpBar = <function> defined @Interface\\AddOns\\GrimUI\\ExpRepBar.lua:27\n ConfigurePartyFrames = <function> defined @Interface\\AddOns\\GrimUI\\PartyFrames.lua:374\n BlizBuildInfo = <function> defined @Interface\\AddOns\\GrimUI\\GDevTools.lua:73\n ShardBarFix = <function> defined @Interface\\AddOns\\GrimUI\\PlayerFrame.lua:35\n ResetPartyFrames = <function> defined @Interface\\AddOns\\GrimUI\\PartyFrames.lua:103\n UnlockFrame = <function> defined @Interface\\AddOns\\GrimUI\\Core.lua:170\n ResetExpRepBar = <function> defined @Interface\\AddOns\\GrimUI\\ExpRepBar.lua:200\n RunSlashCmd = <function> defined @Interface\\AddOns\\GrimUI\\Core.lua:180\n CLASS = <table> {\n }\n TargetDebuffSetup = <function> defined @Interface\\AddOns\\GrimUI\\TargetFrame.lua:789\n ConfigureCombatLog = <function> defined @Interface\\AddOns\\GrimUI\\ChatFr", -- [3]
				"ames.lua:299\n MoneyToString = <function> defined @Interface\\AddOns\\GrimUI\\Core.lua:106\n backpackButton = <unnamed> {\n }\n ShardBarCata = <function> defined @Interface\\AddOns\\GrimUI\\PlayerFrame.lua:106\n ConfigureBlizPlayerFrame = <function> defined @Interface\\AddOns\\GrimUI\\PlayerFrame.lua:13\n targetOfTargetFrame = <unnamed> {\n }\n RegisterEvents = <function> defined @Interface\\AddOns\\GrimUI\\Core.lua:31\n PetHappyFix = <function> defined @Interface\\AddOns\\GrimUI\\PlayerFrame.lua:44\n RegisterEvent = <function> defined @Interface\\AddOns\\GrimUI\\Core.lua:23\n SafeCall = <function> defined @Interface\\AddOns\\GrimUI\\Core.lua:82\n VehicFrameSetup = <function> defined @Interface\\AddOns\\GrimUI\\ActionBars.lua:21\n ShardBarPreCata = <function> defined @Interface\\AddOns\\GrimUI\\PlayerFrame.lua:80\n HideTooltip = <function> defined @Interface\\AddOns\\GrimUI\\Core.lua:132\n OptionsLogo = <function> defined @Interface\\AddOns\\GrimUI\\Settings.lua:69\n ConfigureChatTabs = <function> defined @Interfa", -- [4]
				"ce\\AddOns\\GrimUI\\ChatFrames.lua:285\n ConfigureRepBar = <function> defined @Interface\\AddOns\\GrimUI\\ExpRepBar.lua:39\n configPanel = <table> {\n }\n TargetBuffSetup = <function> defined @Interface\\AddOns\\GrimUI\\TargetFrame.lua:745\n UnregisterEvent = <function> defined @Interface\\AddOns\\GrimUI\\Core.lua:43\n ResetDevBar = <function> defined @Interface\\AddOns\\Grim\n  ---", -- [5]
			},
			["type"] = "error",
			["time"] = "2010/10/08 10:52:48",
			["session"] = 2498,
			["counter"] = 2,
		}, -- [50]
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]

Last edited by Grimsin : 10-08-10 at 12:36 PM.
  Reply With Quote
10-08-10, 12:53 PM   #11
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
To be most specific. This error only happens on a fresh load when their is no buff or debuff in one of the box's ahead of time. When you cast the buff it errors but the buff still appears and where it is supposed to.
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
10-08-10, 01:28 PM   #12
Vrul
A Scalebane Royal Guard
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 404
I think that is because the buff frames are created dynamically in an OnUpdate script so your OnEvent will get run before the OnUpdate can create the frame. Change:
Code:
for index = 1, 40 do
	buffName, _, _, _, _, _, _, buffCaster = UnitBuff('target', index)
	if buffName then
		buff = _G['TargetFrameBuff' .. index]
to:
Code:
for index = 1, 40 do
	buff = _G['TargetFrameBuff' .. index]
	buffName, _, _, _, _, _, _, buffCaster = buff and UnitBuff('target', index)
	if buffName then
  Reply With Quote
10-08-10, 02:00 PM   #13
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
still get the error it just changes. I tried a few different things and all get errors of course all methods it still functions properly. Its all the same type of error buff = nil value. I think your right, maybe instead of using the event i hooksecure function and hook those functions to the update function for the buffs then it shouldnt call my functions until bliz has done its thing.
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]

Last edited by Grimsin : 10-08-10 at 02:15 PM.
  Reply With Quote
10-08-10, 02:29 PM   #14
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
useing a hookfunc did the trick no errors now all appears to be working fine.
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
10-08-10, 02:46 PM   #15
Vrul
A Scalebane Royal Guard
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 404
Since addon.TargetBuffSetup and addon.TargetDebuffSetup are so similar you could replace them with:
Code:
local function ProcessBuffs(name, unitFunc, parentFrameMine, parentFrameOther, scaleMine, scaleOther)
	local buff, caster, frame, _
	local countMine, prevMine, prevRowMine = 0
	local countOther, prevOther, prevRowOther = 0
	for index = 1, 40 do
		frame = _G[name .. index]
		buff, _, _, _, _, _, _, caster = unitFunc('target', index)
		if frame and buff then
			frame:ClearAllPoints()
			if caster ~= 'player' then
				frame:SetParent(parentFrameOther)
				frame:SetScale(scaleOther)
				if countOther % 10 ~= 0 then
					frame:SetPoint('LEFT', prevOther, 'RIGHT', 1, 0)
				else
					if prevRowOther then
						frame:SetPoint('TOP', prevRowOther, 'BOTTOM', 0, 1)
					else
						frame:SetPoint('TOPLEFT')
					end
					prevRowOther = frame
				end
				countOther, prevOther = countOther + 1, frame
			else
				frame:SetParent(parentFrameMine)
				frame:SetScale(scaleMine)
				if countMine % 10 ~= 0 then
					frame:SetPoint('LEFT', prevMine, 'RIGHT', 1, 0)
				else
					if prevRowMine then
						frame:SetPoint('TOP', prevRowMine, 'BOTTOM', 0, 1)
					else
						frame:SetPoint('TOPLEFT')
					end
					prevRowMine = frame
				end
				countMine, prevMine = countMine + 1, frame
			end
		else
			break
		end
	end
end

TargetBuffMainFrame:SetScript('OnEvent', function(self)
	ProcessBuffs('TargetFrameBuff', UnitBuff, TargetIBuffedFrame, TargetBuffedFrame, 1.35, 1)
	ProcessBuffs('TargetFrameDebuff', UnitDebuff, TargetIDebuffedFrame, TargetDebuffedFrame, 1.15, 1)
end)
  Reply With Quote
10-08-10, 04:37 PM   #16
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
hmm those will pase over in a hook func right? and i had to move some of the things inside other areas to stop other erroring same thing as before were buff = nil. in particular was the clearallpoints they had to be moved inside of the individual if statements in order to stop the buff = nil error on them.

heres what it looks like right now. and now dealing with debuff = nil rofl

Code:
-- some nonsense for buffs and the blizz target frame.


local TargetBuffMainFrame = CreateFrame('Frame', "TargetBuffMainFrame", GrimTargetFrame)
TargetBuffMainFrame:SetHeight(125)
TargetBuffMainFrame:SetWidth(410)
TargetBuffMainFrame:SetPoint("BOTTOM", GrimTargetFrame, "TOP")

local TargetIBuffedFrame = CreateFrame('Frame', "TargetIBuffedFrame", GrimTargetFrame)
TargetIBuffedFrame:SetHeight(40)
TargetIBuffedFrame:SetWidth(200)
TargetIBuffedFrame:SetPoint("TOPLEFT", TargetBuffMainFrame, "TOPLEFT")
local tibbg = TargetIBuffedFrame:CreateTexture(nil, "BACKGROUND")
tibbg:SetTexture(0, 0, 0, .7)
tibbg:SetAllPoints(TargetIBuffedFrame)


local TargetIDebuffedFrame = CreateFrame('Frame', "TargetIDebuffedFrame", TargetBuffMainFrame)
TargetIDebuffedFrame:SetHeight(40)
TargetIDebuffedFrame:SetWidth(200)
TargetIDebuffedFrame:SetPoint("TOPRIGHT", TargetBuffMainFrame, "TOPRIGHT")
local tidbbg = TargetIDebuffedFrame:CreateTexture(nil, "BACKGROUND")
tidbbg:SetTexture(0, 0, 0, .7)
tidbbg:SetAllPoints(TargetIDebuffedFrame)



local TargetBuffedFrame = CreateFrame('Frame', "TargetBuffedFrame", TargetBuffMainFrame)
TargetBuffedFrame:SetHeight(80)
TargetBuffedFrame:SetWidth(200)
TargetBuffedFrame:SetPoint("BOTTOMLEFT", TargetBuffMainFrame, "BOTTOMLEFT")
local tbbg = TargetBuffedFrame:CreateTexture(nil, "BACKGROUND")
tbbg:SetTexture(0, 0, 0, .7)
tbbg:SetAllPoints(TargetBuffedFrame)



local TargetDebuffedFrame = CreateFrame('Frame', "TargetDebuffedFrame", TargetBuffMainFrame)
TargetDebuffedFrame:SetHeight(80)
TargetDebuffedFrame:SetWidth(200)
TargetDebuffedFrame:SetPoint("BOTTOMRIGHT", TargetBuffMainFrame, "BOTTOMRIGHT")
local tdbbg = TargetDebuffedFrame:CreateTexture(nil, "BACKGROUND")
tdbbg:SetTexture(0, 0, 0, .7)
tdbbg:SetAllPoints(TargetDebuffedFrame)

function addon:TargetBuffSetup()
    local buff, buffCaster, buffName, _
    local myBuffsCount, myBuffsPrev, myBuffsPrevRow = 0
    local otherBuffsCount, otherBuffsPrev, otherBuffsPrevRow = 0
    for index = 1, 40 do
        buff = _G['TargetFrameBuff' .. index]
        buffName, _, _, _, _, _, _, buffCaster = UnitBuff('target', index)
        
        if buffName then
            
            
            if buffCaster ~= 'player' then
                buff:SetParent(TargetBuffedFrame)
                buff:SetScale(1)
                if otherBuffsCount % 10 ~= 0 then
                    buff:ClearAllPoints()
                    buff:SetPoint('RIGHT', otherBuffsPrev, 'LEFT', 1, 0)
                else
                    if otherBuffsPrevRow then
                        buff:ClearAllPoints()
                        buff:SetPoint('TOP', otherBuffsPrevRow, 'BOTTOM')
                    else
                        buff:ClearAllPoints()
                        buff:SetPoint('TOPRIGHT')
                    end
                    otherBuffsPrevRow = buff
                end
                otherBuffsCount, otherBuffsPrev = otherBuffsCount + 1, buff
            else                
                buff:SetParent(TargetIBuffedFrame)
                buff:SetScale(1.35)
                if myBuffsCount % 10 ~= 0 then
                    buff:ClearAllPoints()
                    buff:SetPoint('RIGHT', myBuffsPrev, 'LEFT', 1, 0)
                else
                    if myBuffsPrevRow then
                        buff:ClearAllPoints()
                        buff:SetPoint('TOP', myBuffsPrevRow, 'BOTTOM')
                    else
                        buff:ClearAllPoints()
                        buff:SetPoint('TOPRIGHT')
                    end
                    myBuffsPrevRow = buff
                end
                myBuffsCount, myBuffsPrev = myBuffsCount + 1, buff
            end
        else
            break
        end
    end
end

function addon:TargetDebuffSetup()
    local debuff, debuffCaster, debuffName, _
    local mydeBuffsCount, mydeBuffsPrev, mydeBuffsPrevRow = 0
    local otherdeBuffsCount, otherdeBuffsPrev, otherdeBuffsPrevRow = 0
    for index = 1, 40 do
        debuff = _G['TargetFrameDebuff' .. index]
        debuffName, _, _, _, _, _, _, debuffCaster = UnitDebuff('target', index)
        if debuffName then
            
            if debuffCaster ~= 'player' then
                debuff:SetParent(TargetDebuffedFrame)
                debuff:SetScale(1)
                if otherdeBuffsCount % 10 ~= 0 then
                    debuff:ClearAllPoints()
                    debuff:SetPoint('LEFT', otherdeBuffsPrev, 'RIGHT', 1, 0)
                else
                    if otherdeBuffsPrevRow then
                        debuff:ClearAllPoints()
                        debuff:SetPoint('TOP', otherdeBuffsPrevRow, 'BOTTOM')
                    else
                        debuff:ClearAllPoints()
                        debuff:SetPoint('TOPLEFT')
                    end
                    otherdeBuffsPrevRow = debuff
                end
                otherdeBuffsCount, otherdeBuffsPrev = otherdeBuffsCount + 1, debuff
            else
                debuff:SetParent(TargetIDebuffedFrame)
                debuff:SetScale(1.15)
                if mydeBuffsCount % 10 ~= 0 then
                    debuff:ClearAllPoints()
                    debuff:SetPoint('LEFT', mydeBuffsPrev, 'RIGHT', 1, 0)
                else
                    if mydeBuffsPrevRow then
                        debuff:ClearAllPoints()
                        debuff:SetPoint('TOP', mydeBuffsPrevRow, 'BOTTOM')
                    else
                        debuff:ClearAllPoints()
                        debuff:SetPoint('TOPLEFT')
                    end
                    mydeBuffsPrevRow = debuff
                end
                mydeBuffsCount, mydeBuffsPrev = mydeBuffsCount + 1, debuff
            end
        else
            break
        end
    end
end


hooksecurefunc("TargetFrame_UpdateAuras", function()
    addon:TargetBuffSetup()
    addon:TargetDebuffSetup()
end)

hooksecurefunc("TargetFrame_UpdateBuffAnchor", function()
    addon:TargetBuffSetup()
    addon:TargetDebuffSetup()
end)
hooksecurefunc("TargetFrame_UpdateDebuffAnchor", function()
    addon:TargetBuffSetup()
    addon:TargetDebuffSetup()
end)

hooksecurefunc("TargetFrame_UpdateAuraPositions", function()
    addon:TargetBuffSetup()
    addon:TargetDebuffSetup()
end)
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
10-08-10, 07:35 PM   #17
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
okay so i think i know why it always gives me that error no mater what. So index = a buff frame number well when it seperates out the buff frames it does it by the buffframe number. So when it puts bufframe 1 into the upper box then trys to call the buffframe for the bottom box buffframe 1? or em i off? im only getting the errors on the debuff frame now buff frame seems to work fine.

It looks like its when i cast a debuff and it trys to setpoints it loses buffs 14 on up in the othersdebuff frame and errors to the point buggrabber throttles and stops catching them. Starting to think the separation of your spells from others is causing more probs then its worth.
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]

Last edited by Grimsin : 10-08-10 at 08:29 PM.
  Reply With Quote
10-08-10, 08:29 PM   #18
Vrul
A Scalebane Royal Guard
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 404
I suggested earlier that you replace:
Code:
for index = 1, 40 do
	buffName, _, _, _, _, _, _, buffCaster = UnitBuff('target', index)
	if buffName then
		buff = _G['TargetFrameBuff' .. index]
with (part you missed in red):
Code:
for index = 1, 40 do
	buff = _G['TargetFrameBuff' .. index]
	buffName, _, _, _, _, _, _, buffCaster = buff and UnitBuff('target', index)
	if buffName then
If you had done that it would remove those errors. That fix was rather short-sighted on my part though (haven't slept in 35+ hours so sue me) and would have caused a bug where the buffs the player cast would not be separated out. That is easily corrected for with (change in red):
Code:
for index = 1, 40 do
	buff = _G['TargetFrameBuff' .. index]
	buffName, _, _, _, _, _, _, buffCaster = UnitBuff('target', index)
	if buff and buffName then
If you feel the need for the hooks still (the first one may actually be needed, to lazy to check Bliz's code) then at least refrain from creating four identical functions:
Code:
local function hook()
	addon:TargetBuffSetup()
	addon:TargetDebuffSetup()
end

hooksecurefunc('TargetFrame_UpdateAuras', hook)
hooksecurefunc('TargetFrame_UpdateBuffAnchor', hook)
hooksecurefunc('TargetFrame_UpdateDebuffAnchor', hook)
hooksecurefunc('TargetFrame_UpdateAuraPositions', hook)
If you want to use the consolidated function I posted earlier then:
Code:
local function hook()
	ProcessBuffs('TargetFrameBuff', UnitBuff, TargetIBuffedFrame, TargetBuffedFrame, 1.35, 1)
	ProcessBuffs('TargetFrameDebuff', UnitDebuff, TargetIDebuffedFrame, TargetDebuffedFrame, 1.15, 1)
end

hooksecurefunc('TargetFrame_UpdateAuras', hook)
hooksecurefunc('TargetFrame_UpdateBuffAnchor', hook)
hooksecurefunc('TargetFrame_UpdateDebuffAnchor', hook)
hooksecurefunc('TargetFrame_UpdateAuraPositions', hook)
  Reply With Quote
10-08-10, 09:12 PM   #19
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
whoa i totally missed that part in red!!!
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
10-08-10, 09:52 PM   #20
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
assuming that removes the errors, i have not been able to test yet, then im going back to the event script rather then the hooks i noticed it was running things to many times and had changed the hooks but even with just one of those hooks it would run both functions twice per spell so yea the event script is a better method i think.

i have not used the consolidated code yet you posted... i keep finding quirks and having to add another if statement like for some reason when you target your own pet his buff icons are bigger.... so i had to make another if statement to downsize when your target = your pet to make all the icons the same size...

Would you say it would really be better to forget the bliz code and recreate something or do you think its better to adjust bliz stuff? and why?

and you should sleep Obi-Vrul-Kanobi, even coding masters need rest.
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » SetPoint when i = 1,40


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