Thread Tools Display Modes
02-24-12, 07:37 AM   #1
dbaaf
A Deviate Faerie Dragon
AddOn Compiler - Click to view compilations
Join Date: Jan 2012
Posts: 18
ArenaEnemyFrames, Macro works, lua doesn't.

Hey guys

i got a problem, I'm trying to move the default arena frames.
I'm new to .lua. just have some experience in html, java and php.
thats my first "add-on". I'm just messing around with it.

I'm using:

PHP Code:
if moveArenaFrames == true then
        ArenaEnemyFrame1
:ClearAllPoints() 
        
ArenaEnemyFrame1:SetPoint("CENTER", -400, -40)
        
ArenaEnemyFrame1:SetScale(1.23)
        
ArenaEnemyFrame2:SetScale(1.23)
        
ArenaEnemyFrame3:SetScale(1.23)
    
end 
thats the error i get:

Code:
Message: Interface\AddOns\Pvptest\pvptest.lua:35: attempt to index global 'ArenaEnemyFrame1' (a nil value)
Time: Fri Feb 24 14:26:09 2012
Count: 1
Stack: Interface\AddOns\Pvptest\pvptest.lua:35: in main chunk

Locals: moveBuffsandDebuffs = true
moveCastbarandResize = true
changeCastBarColor = true
hideMinimap = true
movePartyFrames = true
hideCombatText = true
hidePetFrame = true
removePlayerFrameIcons = true
classColorBars = true
enableClassIcons = true
changeStatusBarText = true
modifyActionBars = true
showCDonActionBars = true
moveUnits = true
debuffScale = 1.2
playerFrameX = 275
playerFrameY = 0
alignFocusWithTarget = false
showDRTracker = true
showArenaTrinkeCD = true
moveArenaFrames = true
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = "attempt to index global 'ArenaEnemyFrame1' (a nil value)"
thats my .lua:

PHP Code:
----------: Config

local moveBuffsandDebuffs 
true    -- move playerbuffs and debuffs                                                        
local moveCastbarandResize 
true    -- move playercastbar and resize                                                        
local changeCastBarColor 
true        -- change target and focus castbarcolor to blue                                                
local hideMinimap 
true             -- hide minimap completely
local movePartyFrames 
true        -- move partyframes to topleft playerframe                                            
local hideCombatText 
true          -- hide combattext on classicon/portrait                                                
local hidePetFrame 
true            -- hide petframe (i dont care about it as priestgot a makro for dispel shadowfiend)    
local removePlayerFrameIcons true -- remove combatstatus and restedglow on playerframe                                    
local classColorBars 
true            -- add classcolor to healthbar
local enableClassIcons 
true        -- classicons instead of portrait                                                    
local changeStatusBarText 
true    -- display max hp AND percent hp                                                        
--
--                                    -- 
playerframeconfig            
--
local moveUnits true                 -- moving playertarget and focus frames                                                
local debuffScale 
1.2                -- adjust debuffscaling (wowdefault "1")                    
local playerFrameX 275            -- vertical adjust playerframe
local playerFrameY 
0                -- horizontal adjust playerframe
local alignFocusWithTarget 
false     -- align focus with target
--                                    
--                                    -- 
ArenaStuff
--                                        
local showDRTracker true            -- track DR left to the ArenaEnemyFrames
local showArenaTrinkeCD 
true        -- track insigniacooldown right to the ArenaEnemyFrames
local moveArenaFrames 
true        -- move ArenaEnemyFrames to topright focusframe

----------: Modifications

----------:1
if  moveBuffsandDebuffs == true then         
        BuffFrame
:ClearAllPoints()         
        
BuffFrame:SetPoint("TOPRIGHT",-10,-10)         
    
end
----------:2
if moveCastbarandResize == true then
        CastingBarFrame
:SetPoint("BOTTOMLEFT",597,75)
        
CastingBarFrame:SetScale(1.23)
    
end
----------:3
 
if changeCastBarColor == true then
    TargetFrameSpellBar
:SetStatusBarColor(0,0.45,0.9
    
TargetFrameSpellBar.SetStatusBarColor = function() end
    FocusFrameSpellBar
:SetStatusBarColor(0,0.45,0.9
    
FocusFrameSpellBar.SetStatusBarColor = function() end
    end
----------:4
if hideMinimap == true then
        MinimapCluster
:Hide()
    
end
----------:5
if movePartyFrames == true then
        
for 2do
        
local f _G["PartyMemberFrame"..i]
        
f:ClearAllPoints()
        
PartyMemberFrame1:ClearAllPoints()
        
PartyMemberFrame1:SetPoint("CENTER", -400,50)
        
f:SetPoint("BOTTOMLEFT"_G["PartyMemberFrame"..(i-1)], "TOPLEFT"020)
    
end
end
----------:6
if hideCombatText == true then
        PetHitIndicator
:ClearAllPoints() 
        
PlayerHitIndicator:ClearAllPoints()
        
end
----------:7        
if hidePetFrame == true then
        PetFrame
:SetAlpha(0)
        
end
----------:8    
if removePlayerFrameIcons == true then
    
function PlayerFrame_UpdateStatus (self)
        
PlayerStatusTexture:Hide()
        
PlayerStatusGlow:Hide()
        
PlayerRestGlow:Hide()
        
PlayerAttackGlow:Hide()
        
PlayerRestIcon:Hide()
        
PlayerAttackIcon:Hide()
        
PlayerAttackBackground:Hide()
    
end
end
----------:9
if classColorBars == true then
    local UnitIsPlayer
UnitIsConnectedUnitClassRAID_CLASS_COLORS =
    
UnitIsPlayerUnitIsConnectedUnitClassRAID_CLASS_COLORS
    local _
, class, c

    local 
function colour(statusbarunit)
    if 
UnitIsPlayer(unit) and UnitIsConnected(unit) and unit == statusbar.unit and UnitClass(unitthen
    _
, class = UnitClass(unit)
    
CUSTOM_CLASS_COLORS and CUSTOM_CLASS_COLORS[class] or RAID_CLASS_COLORS[class]
    
statusbar:SetStatusBarColor(c.rc.gc.b)
    
end
    end

    TargetFrameTextureFramePVPIcon
:SetAlpha(0)

    
hooksecurefunc("UnitFrameHealthBar_Update"colour)
    
hooksecurefunc("HealthBar_OnValueChanged", function(self)
    
colour(selfself.unit)
    
end)

    
local sb _G.GameTooltipStatusBar
    local addon 
CreateFrame("Frame""StatusColour")
    
addon:RegisterEvent("UPDATE_MOUSEOVER_UNIT")
    
addon:SetScript("OnEvent", function()
    
colour(sb"mouseover")
    
end
end
----------:10
if moveUnits == true then
    PlayerFrame
:SetUserPlaced(false)
    
TargetFrame:SetUserPlaced(false)
    
FocusFrame:SetUserPlaced(false)
    
TargetFrameToT:SetUserPlaced(false)
    
local playerFrame CreateFrame("FRAME")
    
playerFrame:RegisterEvent("PLAYER_ENTERING_WORLD")

    
playerFrame:SetScript("OnEvent", function()
        
        
PlayerFrame:ClearAllPoints()
        
PlayerFrame:SetPoint("CENTER",-playerFrameX,-playerFrameY)
        
        
TargetFrame:ClearAllPoints() 
        
TargetFrame:SetPoint("CENTER","PlayerFrame","CENTER"100, -45)
        
        
TargetFrameToT:ClearAllPoints() 
        
TargetFrameToT:SetPoint("CENTER","TargetFrame","CENTER"55, -35)
        
        
local focusFrame CreateFrame("FRAME")
        
focusFrame:RegisterEvent("PLAYER_FOCUS_CHANGED")
        
focusFrame:SetScript("OnEvent", function()
            
FocusFrame:ClearAllPoints()
            if 
alignFocusWithTarget == true then
                FocusFrame
:SetPoint("CENTER",playerFrameX,-playerFrameY-45)
            else
                
FocusFrame:SetPoint("CENTER",playerFrameX,-playerFrameY)
            
end
            FocusFrameToT
:ClearAllPoints()
            
FocusFrameToT:SetPoint("CENTER","FocusFrame","CENTER"55, -35)
            
            if 
alphaNameBackground == true then
                FocusFrameNameBackground
:SetAlpha(0.5)
            
end
        end
)
    
end)
end
----------:11
if enableClassIcons == true then
        UFP
="UnitFramePortrait_Update" UICC="Interface\\TargetingFrame\\UI-Classes-Circles" CIT=CLASS_ICON_TCOORDS UC=UnitClass
        hooksecurefunc
(UFP,function(self) if self.portrait then t=CIT[select(2,UC(self.unit))] if and UnitIsPlayer(self.unitthen self.portrait:SetTexture(UICCself.portrait:SetTexCoord(unpack(t)) else self.portrait:SetTexCoord(0,1,0,1end end end)
    
end
----------:12        
if changeStatusBarText == true then
        TF
=CreateFrame("Frame")TFHB=TargetFrameHealthBar.TextString;TTSB=TextStatusBar_CapDisplayOfNumericValue
        FF
=CreateFrame("Frame")FFHB=FocusFrameHealthBar.TextString;TTSB=TextStatusBar_CapDisplayOfNumericValue
        FF
:SetScript("OnUpdate", function(focus)FFHB:SetText(TTSB(UnitHealth("focus")).."/"..TTSB(UnitHealthMax("focus")).." ("..format("%.0f", ((UnitHealth("focus")/UnitHealthMax("focus"))*100)).."%)"end)
        
TF:SetScript("OnUpdate", function(target)TFHB:SetText(TTSB(UnitHealth("target")).."/"..TTSB(UnitHealthMax("target")).." ("..format("%.0f", ((UnitHealth("target")/UnitHealthMax("target"))*100)).."%)"end)
    
end
----------: ArenaStuff

if moveArenaFrames == true then
        ArenaEnemyFrame1
:ClearAllPoints() 
        
ArenaEnemyFrame1:SetPoint("CENTER", -400, -40)
        
ArenaEnemyFrame1:SetScale(1.23)
        
ArenaEnemyFrame2:SetScale(1.23)
        
ArenaEnemyFrame3:SetScale(1.23)
    
end
----------:13
if showArenaTrinkeCD == true then
        
--        Alience Trinket trt=GetItemIcon(37864)
        --        
Horde Trinket  :  trt=GetItemIcon(70395)
    
        --        
rc trinket icon size

rc
=40;
rfc=CooldownFrame_SetTimer;
aef="ArenaEnemyFrame";
hb="HealthBar";
trt=GetItemIcon(37864)
ctf CreateFrame;
oe="ARENA_OPPONENT_UPDATE"
ve="PLAYER_ENTERING_WORLD"
tr="RIGHT"
LoadAddOn("Blizzard_ArenaUI")

function 
Cr(i)
    
local f=ctf("Frame",nil,UIParent)
    
f:SetPoint(tr,_G[aef..i..hb],tr,100,0)
    
f:SetSize(rc,rc)
    
f.t=f:CreateTexture(nil,"BORDER")
    
f.t:SetAllPoints(true)
    
f.t:SetTexture(trt)
    
f.c=CreateFrame("Cooldown",nil,f)
    
f.c:SetAllPoints(f)
    return 
f;
end

function ur(f,i)
    
f:SetScript("OnEvent",
    function(
_,e,u,_,_,_,s)
        if(
u=="arena"..i)then
            
if(s==42292 or s==59752)then
                rfc
(f.c,GetTime(),120,1)
            elseif(
s==7744)then
                rfc
(f.c,GetTime(),30,1)
            
end
        end
    end
)
    
f:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED")
end

for i=1,do
    
_G["rf"..i]=Cr(i)
    
local f=_G["rf"..i]
    
ur(f,i)
    
f:Hide()    
end

function str(o,m)
    for 
i=1do
        
local f=_G["rf"..i]
        if 
o then
            f
:Show()
        else
            
f:Hide()
            
f.c:Hide()        
        
end
    end
end

tk
=ctf("Frame")
tk:SetScript("OnEvent",
function(
_,e)
    if 
e==oe then
        str
(1,GetNumArenaOpponents())
    else
        
str(nil,5)
    
end
end
)
tk:RegisterEvent(oe)
tk:RegisterEvent(ve)
end
----------: 14
if showDRTracker == true then
        
--        drx x position
        
--        drs icon size
        
DRt
={
    {
5782,8122,5484,20511,2094}, -- FEAR
    
{118,6770,1776,49203,28272,28271,61305,61721,61780,82691,51514} -- POLYMORPHE
}

drx=-120;
drs=40;
dp="LEFT";
dre="COMBAT_LOG_EVENT_UNFILTERED"
drp="PLAYER_ENTERING_WORLD"
dra="ARENA_OPPONENT_UPDATE"
LoadAddOn("Blizzard_ArenaUI")
function 
gaef(f,n)return _G["ArenaEnemyFrame"..n.."HealthBar"]end


function rDR(f)
    
f.e=1;
    
f.t:SetTexture(nil)
    
f.c:Hide()
end

function sDR(f)
    
f.e=f.e+1;
    
f.c:Show()
end

function gDRt(i,j)
    return 
_G["drc"..i..":"..j]
end

function runDR(f,n)
    
CooldownFrame_SetTimer(f.c,GetTime(),18,1)
    
eDR(f,n)            
    
sDR(f)                    
    
oDR(n)
end

function eDR(f,n)
    
local t=1;
    
f:SetScript("OnUpdate",
    function(
s,e)
        
t=t+e;
        if(
t>=18)then
            f
:SetScript("OnUpdate",nil)
            
rDR(f)
            
oDR(n)
        
end        
    end
)
end

function cDR(f,n,s)
    if 
f.e<4 then    
        local _
,_,t=GetSpellInfo(s)
        
f.t:SetTexture(t)
        
runDR(f,n)
    
end
end

function oDR(n)
    
local r=1;
    for 
j in ipairs(DRt)do
        
local f=gDRt(n,j)
        
f:SetPoint(dp,gaef(f,n),dp,drx+(r-1)*50,0)
        
r=r+1;
    
end
end

function uDR(n,s)
    for 
i,t in ipairs(DRt)do
        for 
_,j in ipairs(t)do
            if 
s==j then
                cDR
(gDRt(n,i),n,s)                        
            
end
        end
    end
end

function DRc(i,j)
    
local f=CreateFrame("Frame",nil,UIParent)
    
f:SetSize(drs,drs)
    
f.t=f:CreateTexture(nil,"BORDER")
    
f.t:SetAllPoints(true)
    
f.c=CreateFrame("Cooldown",nil,f)
    
f.c:SetAllPoints(f)    
    
f.e=1
    
return f
end

function clDR(_,e,_,_,_,_,_,d,_,_,_,s)
    if(
e=="SPELL_AURA_REMOVED" or e=="SPELL_AURA_REFRESH")then
        
for i=1,do
            
local ag=UnitGUID("arena"..i)
            if(
ag ~= nil and d==ag)then
                uDR
(i,s)
            
end
        end
    end
end

function iDRt(o,m)
    for 
i=1,do
        for 
j in ipairs(DRt)do
            
local f=gDRt(i,j)
            
rDR(f)
            if 
o then                
                f
:Show()
            
end
        end
    end
end

for i=1,do
    for 
j in ipairs(DRt)do
        
_G["drc"..i..":"..j]=DRc(i,j)
    
end
end

dt
=CreateFrame("Frame")
dt:SetScript("OnEvent",
    function(
_,e,...)
        if 
e==dre then
            clDR
(...)
        elseif 
e==dra then
            iDRt
(1,GetNumArenaOpponents())
        else    
            
iDRt(nil,5)    
        
end    
    end
)
dt:RegisterEvent(dra)
dt:RegisterEvent(drp)
dt:RegisterEvent(dre)
end
----------: End ArenaStuff 
i can't even move the arenaframes anywhere... i have no clue whats wrong

if i make a macro like:

Code:
/run ArenaEnemyFrame1:ClearAllPoints() 
/run ArenaEnemyFrame1:SetPoint("CENTER", -400, -40)
/run ArenaEnemyFrame1:SetScale(1.23)
/run ArenaEnemyFrame2:SetScale(1.23)
/run ArenaEnemyFrame3:SetScale(1.23)
it just works fine

hope someone can help me out!

regards
dbaaf
__________________

Last edited by dbaaf : 02-24-12 at 07:41 AM.
  Reply With Quote
02-24-12, 08:15 AM   #2
Barjack
A Black Drake
AddOn Author - Click to view addons
Join Date: Apr 2009
Posts: 89
I notice you have a couple of calls to LoadAddOn("Blizzard_ArenaUI") in there, but the error is occurring before the first one of those (you call it the first time in block "13" but the frames are trying to be moved just after block "12"). You need to make sure the arena UI addon is loaded before doing anything with those frames.
  Reply With Quote
02-24-12, 08:35 AM   #3
dbaaf
A Deviate Faerie Dragon
AddOn Compiler - Click to view compilations
Join Date: Jan 2012
Posts: 18
Originally Posted by Barjack View Post
I notice you have a couple of calls to LoadAddOn("Blizzard_ArenaUI") in there, but the error is occurring before the first one of those (you call it the first time in block "13" but the frames are trying to be moved just after block "12"). You need to make sure the arena UI addon is loaded before doing anything with those frames.
its working now barjack.

added LoadAddOn("Blizzard_ArenaUI") on top. i am still at the beginning how to do that and still have to learn a lot.

thank you
__________________
  Reply With Quote
02-24-12, 01:16 PM   #4
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Don't force the Blizz Arena addon to load. Instead, set your addon to load with the Arena addon. Then, your code will execute only when it needs to.

http://www.wowpedia.org/TOC_format
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
02-24-12, 11:18 PM   #5
dbaaf
A Deviate Faerie Dragon
AddOn Compiler - Click to view compilations
Join Date: Jan 2012
Posts: 18
thanks!

added ## OptionalDeps: Blizzard_ArenaUI works fine
__________________
  Reply With Quote
02-25-12, 12:02 AM   #6
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
But that's not what I recommended you do.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
02-25-12, 03:43 AM   #7
Talyrius
An Onyxian Warder
 
Talyrius's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 363
If you had continued to look over Seerah's link, you would have found the following to be the proper solution.
Code:
## LoadOnDemand: 1
## LoadWith: Blizzard_ArenaUI
Of course, you would only use the above method if the scope of your particular addon was only to modify the arena frames.

Otherwise, you would do something like this:
lua Code:
  1. local function myArenaStuff()
  2.     -- Do stuff here.
  3. end
  4.  
  5. if IsAddOnLoaded("Blizzard_ArenaUI") then
  6.     myArenaStuff()
  7. else
  8.     local f = CreateFrame("Frame")
  9.     f:RegisterEvent("ADDON_LOADED")
  10.     f:SetScript("OnEvent", function(self, event, addonName)
  11.         if addonName ~= "Blizzard_ArenaUI" then
  12.             return
  13.         end
  14.        
  15.         myArenaStuff()
  16.        
  17.         self:UnregisterEvent("ADDON_LOADED")
  18.         self:SetScript("OnEvent", nil)
  19.     end)
  20. end
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » ArenaEnemyFrames, Macro works, lua doesn't.


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