Thread Tools Display Modes
04-22-09, 07:37 AM   #1
Nubsy
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 14
Help please

Hi im new to all this jst so u now but ive bn fidling around with the draggable frames.I can get the frames to be draged but i cant lock them in place can some 1 plz tell me whats im doing wrong.

here is the code.
-- Spawn Frames --
local player = oUF:Spawn("player", "oUF_Player"):SetPoint("CENTER", -230, -240)
local target = oUF:Spawn("target", "oUF_Target"):SetPoint("CENTER", 231, -240)
local pet = oUF:Spawn("pet", "oUF_pet")
pet:SetPoint("TOPRIGHT", player, "BOTTOMRIGHT", -0, -1)
local tt = oUF:Spawn("targettarget")
tt:SetPoint("TOPRIGHT", target, "BOTTOMRIGHT", 0, -1)


-- Frame Moving Func --


-- move func
local function oUF_MoveThisFrame(frame,moveit,lock)
local f = _G[frame]
if moveit == 1 then
f:SetMovable(true)
f:SetUserPlaced(true)
if lock ~= 1 then
f:EnableMouse(true)
f:RegisterForDrag("RightButton")
f:SetScript("OnDragStart", function(self) self:StartMoving() end)
f:SetScript("OnDragStop", function(self) self:StopMovingOrSizing() end)
end
else
f:IsUserPlaced(false)
end
end

-- create drag frame func
local function oUF_CreateDragFrame(framename,movable,locked,anchorframe,anchorframename,anchorpoint,xpos,ypos)
local f = CreateFrame("Frame",framename,UIParent)
f:SetWidth(50)
f:SetHeight(50)
if locked ~= 1 then
f:SetBackdrop({bgFile = "Interface/Tooltips/UI-Tooltip-Background", edgeFile = "", tile = true, tileSize = 16, edgeSize = 16, insets = { left = 0, right = 0, top = 0, bottom = 0 }})
end
f:SetPoint(anchorpoint,xpos,ypos)
f:SetFrameStrata("DIALOG")
if anchorframe == nil then
anchorframe = _G[anchorframename]
end
anchorframe:ClearAllPoints()
anchorframe:SetPoint("TOPLEFT", f, "TOPLEFT",0,0)
oUF_MoveThisFrame(framename,movable,locked)
end

--calls
-- oUF_CreateDragFrame(framename,movable,locked,anchorframe,anchorframename,anchorpoint,xpos,ypos)
oUF_CreateDragFrame("oUF_TargetDragFrame",1,0,target,"oUF_Target","CENTER",0,0)
id like to thank roth for the code
  Reply With Quote
04-22-09, 07:51 AM   #2
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Just look at the function call.
Code:
--calls
-- oUF_CreateDragFrame(framename,movable,locked,anchorframe,anchorframename,anchorpoint,xpos,ypos)
oUF_CreateDragFrame("oUF_TargetDragFrame",1,0,target,"oUF_Target","CENTER",0,0)
You are calling the function with locked = 0. To lock it the 0 has to be 1. Its an example only. You need to replace the values with variables that stand for your move or lock-status.

Something like this. Your player and target variables and global names may be named differently too.
Code:
--calls
local moveplayer = 1
local lockplayer = 1
oUF_CreateDragFrame("oUF_PlayerDragFrame",moveplayer ,lockplayer ,player,"ouf_player","CENTER",0,0)
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
  Reply With Quote
04-22-09, 08:19 AM   #3
Nubsy
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 14
ah kk ill try it out tnx for the fast reply

Last edited by Nubsy : 04-22-09 at 09:27 AM.
  Reply With Quote
04-22-09, 09:28 AM   #4
Nubsy
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 14
now every time i make a lock+unlock command i get

interface\addon\oUF_Nubsy\oUF_nubsy.lau:549: attempt to index local 'anchorframe' (a nil value)

how do i set value to this ? :S
  Reply With Quote
04-22-09, 10:51 AM   #5
Luzzifus
A Warpwood Thunder Caller
 
Luzzifus's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2007
Posts: 94
Originally Posted by Nubsy View Post
now every time i make a lock+unlock command i get

interface\addon\oUF_Nubsy\oUF_nubsy.lau:549: attempt to index local 'anchorframe' (a nil value)

how do i set value to this ? :S
According to your code you don't create an anchorframe.
  Reply With Quote
04-22-09, 10:17 PM   #6
Nubsy
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 14
Ok i worked around it but how do i set it to lock the frames were thay are

i tried local lock = 1 but nuffin eny help please ?
  Reply With Quote
04-23-09, 01:47 AM   #7
Luzzifus
A Warpwood Thunder Caller
 
Luzzifus's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2007
Posts: 94
Well I actually misunderstood what the anchorframe is in CreateDragFrame. What you have to do is to call this function once for every unit frame you want to move (e.g. after spawning). The last line of your code is just an example of this.

Everytime you want to lock or unlock your frames you need to call MoveThisFrame.

Note that the drag frames created by those functions are really simple. If you want them to look like in my example in the other thread you have to do more sizing and positioning. Another note, it's generally very helpful trying to understand other people's code before simply copy-pasting it.

Last edited by Luzzifus : 04-23-09 at 01:53 AM.
  Reply With Quote
04-24-09, 03:43 PM   #8
Nubsy
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 14
tnx for the help guys i eventually got it 2 work

but 1 thing i cant get to work is making the castbars dragable ive tried using
oUF_CreateDragFrame("ouf_CastBarDragFrame",move_castbar ,lock_castbar,"ouf_castbar","CENTER", 1, 0)
and
oUF_CreateDragFrame("ouf_statusbarDragFrame",move_statusbar ,lock_statusbar,"ouf_statusbar","CENTER", 1, 0)
but none work the code i use is
if(unit == 'player') then
local colorcb
local _,classcb = UnitClass(unit)
colorcb = oUF.colors.class[classcb]

self.Castbar = CreateFrame('StatusBar', nil, self)
self.Castbar:SetPoint('TOP', Player, 'CENTER', -230, -193) ---castbar position---
self.Castbar:SetStatusBarTexture(texturebar)
self.Castbar:SetStatusBarColor(colorcb[1], colorcb[2], colorcb[3])
self.Castbar:SetBackdrop(backdrophp)
self.Castbar:SetBackdropColor(colorcb[1]/3, colorcb[2]/3, colorcb[3]/3)
self.Castbar:SetHeight(19) ----change to set hite-----
self.Castbar:SetWidth(292) ----change to set width----

self.Castbar.Spark = self.Castbar:CreateTexture(nil,'OVERLAY')
self.Castbar.Spark:SetBlendMode("ADD")
self.Castbar.Spark:SetHeight(55)
self.Castbar.Spark:SetWidth(27)
self.Castbar.Spark:SetVertexColor(colorcb[1], colorcb[2], colorcb[3])

self.Castbar.Text = setFontString(self.Castbar, fontn, 13)
self.Castbar.Text:SetPoint('LEFT', self.Castbar, 2, 0)

self.Castbar.Time = setFontString(self.Castbar, fontn, 13)
self.Castbar.Time:SetPoint('RIGHT', self.Castbar, -2, 0)
self.Castbar.CustomTimeText = OverrideCastbarTime

self.Castbar2 = CreateFrame('StatusBar', nil, self.Castbar)
self.Castbar2:SetPoint('BOTTOMRIGHT', self.Castbar, 'BOTTOMRIGHT', 4, -4)
self.Castbar2:SetPoint('TOPLEFT', self.Castbar, 'TOPLEFT', -4, 4)
self.Castbar2:SetBackdrop(backdrop)
self.Castbar2:SetBackdropColor(0,0,0,1)
self.Castbar2:SetHeight(27)
self.Castbar2:SetFrameLevel(0)

self.Castbar.SafeZone = self.Castbar:CreateTexture(nil,'BACKGROUND')
self.Castbar.SafeZone:SetPoint('TOPRIGHT')
self.Castbar.SafeZone:SetPoint('BOTTOMRIGHT')
self.Castbar.SafeZone:SetHeight(20)
self.Castbar.SafeZone:SetTexture(texturebar)
self.Castbar.SafeZone:SetVertexColor(1,1,.01,0.5)
--]]
end
if(unit == 'target') then
self.Castbar = CreateFrame('StatusBar', nil, self)
self.Castbar:SetPoint('TOP', Target, 'CENTER', 158, -268) ----sets position----
self.Castbar:SetStatusBarTexture(texturebar)
self.Castbar:SetStatusBarColor(.81,.81,.25)
self.Castbar:SetBackdrop(backdrophp)
self.Castbar:SetBackdropColor(.81/3,.81/3,.25/3)
self.Castbar:SetHeight(20) ----sets hight----
self.Castbar:SetWidth(146) ----sets width----

self.Castbar.Text = setFontString(self.Castbar, fontn, 12)
self.Castbar.Text:SetPoint('LEFT', self.Castbar, 2, 0)

self.Castbar.Time = setFontString(self.Castbar, fontn, 12)
self.Castbar.Time:SetPoint('RIGHT', self.Castbar, -2, 0)
self.Castbar.CustomTimeText = OverrideCastbarTime

self.Castbar2 = CreateFrame('StatusBar', nil, self.Castbar)
self.Castbar2:SetPoint('BOTTOMRIGHT', self.Castbar, 'BOTTOMRIGHT', 4, -4)
self.Castbar2:SetPoint('TOPLEFT', self.Castbar, 'TOPLEFT', -4, 4)
self.Castbar2:SetBackdrop(backdrop)
self.Castbar2:SetBackdropColor(0,0,0,1)
self.Castbar2:SetHeight(21)
self.Castbar2:SetFrameLevel(0)

self.Castbar.Spark = self.Castbar:CreateTexture(nil,'OVERLAY')
self.Castbar.Spark:SetBlendMode("Add")
self.Castbar.Spark:SetHeight(35)
self.Castbar.Spark:SetWidth(25)
self.Castbar.Spark:SetVertexColor(.69,.31,.31)
end
eny help there please
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » Help please


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