AddOn help

Snack

Salty
So I have been using a couple of scripts for arena frames + PvP trinket tracking. I just learned about making your own AddOns; creating lua files so the scripts load upon login, and I have been messing around with it. I got a couple of scripts working, but the one for arena frames/PvP trinket is anoying me.

Here are my scripts taken from my ingame macro menu:
These sets the position of the frames and scales them up:

Code:
/run TR="TOPRIGHT" ArenaEnemyFrame1:ClearAllPoints() ArenaEnemyFrame2:ClearAllPoints() ArenaEnemyFrame1:SetPoint(TR,-150,-40) ArenaEnemyFrame2:SetPoint(TR,-150,-90) 

/run ArenaEnemyFrame1.SetPoint = function() end ArenaEnemyFrame2.SetPoint = function() end
/run ArenaEnemyFrame1:SetScale(1.4)
/run ArenaEnemyFrame2:SetScale(1.4)


These are for PvP trinkets:
Code:
/run rc=36;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")

/run function Cr(i)local f=ctf("Frame",nil,UIParent)f:SetPoint(tr,_G[aef..i..hb],tr,80,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

/run 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

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

/run 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)
and this is my AddOn (which isn't working):



Code:
TR="TOPRIGHT" ArenaEnemyFrame1:ClearAllPoints() ArenaEnemyFrame2:ClearAllPoints() ArenaEnemyFrame1:SetPoint(TR,-150,-40) ArenaEnemyFrame2:SetPoint(TR,-150,-90) end


ArenaEnemyFrame1.SetPoint = function() end 

ArenaEnemyFrame2.SetPoint = function() end 


ArenaEnemyFrame1:SetScale(1.4) end


ArenaEnemyFrame2:SetScale(1.4) end


rc=36;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,80,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,5 do _G["rf"..i]=Cr(i)local f=_G["rf"..i]ur(f,i)f:Hide()end function str(o,m)for i=1, 2 do 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)






I have no idea what I am doing wrong, it does show the PvP trinkets, but doesn't scale/move arena frames. Any help would be greatly appreciated!
 
So I got the arena frames script working, but now I have another issue. An AddOn to move my frame, my target frame, my focus frame, focus ToT frame and target ToT frame. This is the lua file:

Code:
-- This file is loaded from "Frames.toc"
local f = CreateFrame("Frame")
f:RegisterEvent("PLAYER_LOGIN");
f:SetScript("OnEvent",function(self,event,...)
        if event=="PLAYER_LOGIN" then


PlayerFrame:ClearAllPoints()
PlayerFrame:SetPoint("LEFT",540,100)


TargetFrame:ClearAllPoints()
TargetFrame:SetPoint("LEFT",1060,100)


FocusFrame:ClearAllPoints()
FocusFrame:SetPoint("LEFT",340,40)


FocusFrameToT:ClearAllPoints()
FocusFrameToT:SetPoint("LEFT",130,-47)


TargetFrameToT:ClearAllPoints()
TargetFrameToT:SetPoint("LEFT",133,-48)


end)

Can anyone help me?
 
Try this

Frame:SetMovable(enable)
Î
(Name of The Frame)
 
Last edited by a moderator:
Before end)
Can you please edit it into my code, the place where you would write it, really can't get this to work:

Code:
-- This file is loaded from "TargetFrames.toc"


local f = CreateFrame("Frame")
f:RegisterEvent("PLAYER_LOGIN")
f:SetScript("OnEvent",function)
PlayerFrame:ClearAllPoints()
PlayerFrame:SetPoint("LEFT",540,100)


TargetFrame:ClearAllPoints()
TargetFrame:SetPoint("LEFT",1060,100)


FocusFrame:ClearAllPoints()
FocusFrame:SetPoint("LEFT",340,40)


FocusFrameToT:ClearAllPoints()
FocusFrameToT:SetPoint("LEFT",130,-47)


TargetFrameToT:ClearAllPoints()
TargetFrameToT:SetPoint("LEFT",133,-48)


self:UnregisterEvent("PLAYER_LOGIN")

end)
 
Last edited by a moderator:
I have no idea why, but this seems to work:
Code:
-- This file is loaded from "TargetFrames.toc"


local f = CreateFrame("Frame")
f:RegisterEvent("PLAYER_LOGIN")
f:SetScript("OnEvent",function(self,event,...)


PlayerFrame:ClearAllPoints()
PlayerFrame:SetPoint("LEFT",540,100)


TargetFrame:ClearAllPoints()
TargetFrame:SetPoint("LEFT",1060,100)


FocusFrame:ClearAllPoints()
FocusFrame:SetPoint("LEFT",340,40)


FocusFrameToT:ClearAllPoints()
FocusFrameToT:SetPoint("LEFT",130,-47)


TargetFrameToT:ClearAllPoints()
TargetFrameToT:SetPoint("LEFT",133,-48)


PlayerFrame:SetUserPlaced(true)


TargetFrame:SetUserPlaced(true)


FocusFrame:SetUserPlaced(true)


FocusFrameToT:SetUserPlaced(true)


TargetFrameToT:SetUserPlaced(true)




self:UnregisterEvent("PLAYER_LOGIN")




end)
 
Because
Frame:SetUserPlaced(true) saves the position of this frame where you have moved .
My code would do it the same but only temporary , good job :)
 
Do you specifically want to use just your own code or are you open to using a premade addon? There are many out there that will accomplish what you are try to do.

/cheers
 
Because
Frame:SetUserPlaced(true) saves the position of this frame where you have moved .
My code would do it the same but only temporary , good job :)
Why thank you! :) Only took me 3 days to figure out lmao
Do you specifically want to use just your own code or are you open to using a premade addon? There are many out there that will accomplish what you are try to do.

/cheers
Yeah I want to write it myself. Used to use like 1mil addons, now I feel like going back to basics. Still configuring my UI alot, but only through self-written scripts. This way I feel like it allows me to really config it the way I want it, and give me a better idea of what is going on in my UI. + it's pretty neat to have done it yourself imo
 
Yeah I want to write it myself. Used to use like 1mil addons, now I feel like going back to basics. Still configuring my UI alot, but only through self-written scripts. This way I feel like it allows me to really config it the way I want it, and give me a better idea of what is going on in my UI. + it's pretty neat to have done it yourself imo

Thats right!
 

Users who are viewing this thread

Top