WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   oUF (Otravi Unit Frames) (https://www.wowinterface.com/forums/forumdisplay.php?f=87)
-   -   Help please (https://www.wowinterface.com/forums/showthread.php?t=22686)

Nubsy 04-22-09 07:37 AM

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.
Quote:

-- 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 :)

zork 04-22-09 07:51 AM

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)


Nubsy 04-22-09 08:19 AM

ah kk ill try it out tnx for the fast reply :)

Nubsy 04-22-09 09:28 AM

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

Luzzifus 04-22-09 10:51 AM

Quote:

Originally Posted by Nubsy (Post 130013)
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.

Nubsy 04-22-09 10:17 PM

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 ?

Luzzifus 04-23-09 01:47 AM

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.

Nubsy 04-24-09 03:43 PM

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
Quote:

oUF_CreateDragFrame("ouf_CastBarDragFrame",move_castbar ,lock_castbar,"ouf_castbar","CENTER", 1, 0)
and
Quote:

oUF_CreateDragFrame("ouf_statusbarDragFrame",move_statusbar ,lock_statusbar,"ouf_statusbar","CENTER", 1, 0)
but none work the code i use is
Quote:

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 :)


All times are GMT -6. The time now is 01:05 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI