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

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