Quantcast a means of checking if a frame exists - Page 2 - WoWInterface
Thread Tools Display Modes
01-31-12, 04:38 PM   #21
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
That ensures the file it's included in has an upvalued version of the name and the shared table. Personally, I prefer NOT putting that table in the global space and instead using it as a shared private namespace.
How do you do that? Originally my goal was to setup a core file that i could put functions in that would be later used in other files as well as setup a handful of things.

Also i have my options and settings setup for LOD thanks to Vrul so i needed functions in my files to not only work within the addon but as well as with the LOD options files. If its made a private name space will the LOD config still be able to pull the functions?

This is currently what my core looks like...
Code:
local addonName, addon = ...
_G[addonName] = addon

--[[-----------------------------------------------------------------------------
Event handling - Use one frame to process multiple individual OnEvent needs
-------------------------------------------------------------------------------]]
do
	local frame, select, next, events = CreateFrame('Frame'), select, pairs({ })
	--local frame, select, next, events = CreateFrame('Frame'), select, next, {} -- maybe a fix? but no...
	local register, unregister = frame.RegisterEvent, frame.UnregisterEvent
	frame:Hide()

	frame:SetScript('OnEvent', function(self, event, ...)
		for reference, func in next, events[event], nil do
			func(reference, event, ...)
		end
	end)

	function addon.RegisterEvent(reference, event, func)
		if not events[event] then
			events[event] = { }
			register(frame, event)
		end
		events[event][reference] = func
	end

	function addon.RegisterEvents(reference, func, ...)
		local event
		for index = 1, select('#', ...) do
			event = select(index, ...)
			if not events[event] then
				events[event] = { }
				register(frame, event)
			end
			events[event][reference] = func
		end
	end

	function addon.UnregisterEvent(reference, event)
		if events[event] then
			events[event][reference] = nil
			if not next(events[event]) then
				events[event] = nil
				unregister(frame, event)
			end
		end
	end

	function addon.UnregisterAllEvents(reference)
		for event, registry in next, events, nil do
			registry[reference] = nil
			if not next(registry) then
				events[event] = nil
				unregister(frame, event)
			end
		end
	end
end

--[[-----------------------------------------------------------------------------
SafeCall - Queue a method of addon to run once combat ends if needed
-------------------------------------------------------------------------------]]
do
	local combatLockdown, queue = InCombatLockdown(), { }

	addon.RegisterEvent("Core-SafeCall-EnterCombat", 'PLAYER_REGEN_DISABLED', function(self)
		combatLockdown = true
	end)

	addon.RegisterEvent("Core-SafeCall-LeaveCombat", 'PLAYER_REGEN_ENABLED', function(self)
		combatLockdown = nil
		for method, arg in pairs(queue) do
			addon[method](addon, arg)
			queue[method] = nil
		end
	end)

	function addon:SafeCall(method, arg)
		if combatLockdown then
			queue[method] = arg or false
		else
			addon[method](addon, arg)
		end
	end
end

--[[-----------------------------------------------------------------------------
Localized class name to file class name look up table
-------------------------------------------------------------------------------]]
local CLASS = { }
for fileName, localName in pairs(LOCALIZED_CLASS_NAMES_MALE) do
	CLASS[localName] = fileName
end
for fileName, localName in pairs(LOCALIZED_CLASS_NAMES_FEMALE) do
	CLASS[localName] = fileName
end
addon.CLASS = CLASS

--[[-----------------------------------------------------------------------------
MoneyToString - Get formatted text from an ammount of copper
-------------------------------------------------------------------------------]]
function addon:MoneyToString(ammount, forceIcons)
	if type(ammount) ~= 'number' then
		ammount = 0
	end
	local cu = ammount % 100
	ammount = floor(ammount / 100)
	local ag, au = ammount % 100, floor(ammount / 100)
	local cuInd, agInd, auInd
	if GetCVarBool('showChatIcons') or forceIcons then
		cuInd = [[|TInterface\MoneyFrame\UI-CopperIcon:0|t]]
		agInd = [[|TInterface\MoneyFrame\UI-SilverIcon:0|t ]]
		auInd = [[|TInterface\MoneyFrame\UI-GoldIcon:0|t ]]
	else
		cuInd = "|cffeda55fc|r"
		agInd = "|cffc7c7cfs|r "
		auInd = "|cffffd700g|r "
	end
	local string = ""
	if au > 0 then
		string = au .. auInd .. ag .. agInd
	elseif ag > 0 then
		string = ag .. agInd
	end
	return string .. cu .. cuInd
end

--[[-----------------------------------------------------------------------------
DoNothing - A simple dummie/do nothing function
-------------------------------------------------------------------------------]]
local function DoNothing()
end
addon.DoNothing = DoNothing

--[[-----------------------------------------------------------------------------
SetUIScale - Set UI Scale to its smallest size.
-------------------------------------------------------------------------------]]
function addon:SetUIScale()
	SetCVar("useUiScale", 1)
	SetCVar( "uiScale", 0.63999998569489);
end

--[[-----------------------------------------------------------------------------
HideTooltip - Hide GameTooltip (several frames use this)
-------------------------------------------------------------------------------]]
function addon:HideTooltip()
	GameTooltip:Hide()
	self.tooltip = nil
end

--[[-----------------------------------------------------------------------------
HideFrame - Hide a frame, prevents it from being reshown
-------------------------------------------------------------------------------]]
function addon:HideFrame(reference)
	local frame = type(reference) == 'string' and _G[reference] or reference
	if type(frame) ~= 'table' then return end
	frame.Show = DoNothing
	frame:Hide()
end

--[[-----------------------------------------------------------------------------
ShowFrame - Show a frame, undoing :HideFrame behavior
-------------------------------------------------------------------------------]]
function addon:ShowFrame(reference)
	local frame = type(reference) == 'string' and _G[reference] or reference
	if type(frame) ~= 'table' then return end
	frame.Show = nil
	frame:Show()
end

--[[-----------------------------------------------------------------------------
LockFrame - Lock a frame, prevents SetPoint and ClearAllPoints from working
-------------------------------------------------------------------------------]]
function addon:LockFrame(reference)
	local frame = type(reference) == 'string' and _G[reference] or reference
	if type(frame) ~= 'table' then return end
	frame.SetPoint = DoNothing
	frame.ClearAllPoints = DoNothing
end

--[[-----------------------------------------------------------------------------
UnlockFrame - Undo :LockFrame
-------------------------------------------------------------------------------]]
function addon:UnlockFrame(reference)
	local frame = type(reference) == 'string' and _G[reference] or reference
	if type(frame) ~= 'table' then return end
	frame.SetPoint = nil
	frame.ClearAllPoints = nil
end

--[[-----------------------------------------------------------------------------
RunSlashCmd - This no longer functions correctly as of patch 4.3
-------------------------------------------------------------------------------]]
local _G = _G
function addon:RunSlashCmd(cmd)
  local slash, rest = cmd:match("^(%S+)%s*(.-)$")
  for name, func in pairs(SlashCmdList) do
     local i, slashCmd = 1
     repeat
        slashCmd, i = _G["SLASH_"..name..i], i + 1
        if slashCmd == slash then
           return true, func(rest)
        end
     until not slashCmd
  end
  -- Okay, so it's not a slash command. It may also be an emote.
  local i = 1
  while _G["EMOTE" .. i .. "_TOKEN"] do
     local j, cn = 2, _G["EMOTE" .. i .. "_CMD1"]
     while cn do
        if cn == slash then
           return true, DoEmote(_G["EMOTE" .. i .. "_TOKEN"], rest);
        end
        j, cn = j+1, _G["EMOTE" .. i .. "_CMD" .. j]
     end
     i = i + 1
  end
end 

--[[-----------------------------------------------------------------------------
GetSlashFunc - returns a slash command function on success or an informative error function on failure.
-------------------------------------------------------------------------------]]
function addon:GetSlashFunc(cmd)
	if not cmd then
		return function(cmd) print("You must supply a command.") end
	end
	if cmd:sub(1, 1) ~= "/" then
		cmd = "/" .. cmd
	end
	for id, val in pairs(_G) do
		if id:sub(1, 5) == "SLASH" and val == cmd then
			local slashID = id:match("SLASH_(%a*)%d*")
			return SlashCmdList[slashID]
		end
	end
	-- Didn't find one?
	return function(cmd) print(cmd, "doesn't exist.") end
end

--[[-----------------------------------------------------------------------------
Decimal Truncate Function
-------------------------------------------------------------------------------]]
function addon:truncate(number, decimals)
    return number - (number % (0.1 ^ decimals))
end

--[[-----------------------------------------------------------------------------
Class/Reaction type Coloring
-------------------------------------------------------------------------------]]
do 
	local format = string.format
	GCHex = function(color)
		return format('|cff%02x%02x%02x', color.r * 255, color.g * 255, color.b * 255)
	end
end
function addon:unitColor(unit)
	local color = { r=1, g=1, b=1 }
	if UnitIsPlayer(unit) then
		local _, class = UnitClass(unit)
		color = RAID_CLASS_COLORS[class]
		return color
	else
		local reaction = UnitReaction(unit, "player")
		if reaction then
			color = FACTION_BAR_COLORS[reaction]
			return color
		end
	end
	return color
end

--[[-----------------------------------------------------------------------------
Durability % Coloring
-------------------------------------------------------------------------------]]
local tmpString = ""
function addon:DurColor(percent)
	if percent >= 80 then
		tmpString = "|cff00FF00"
	elseif percent >= 60 then
		tmpString = "|cff99FF00"
	elseif percent >= 40 then
		tmpString = "|cffFFFF00"
	elseif percent >= 20 then
		tmpString = "|cffFF9900"
	elseif percent >= 0 then
		tmpString = "|cffFF2000"
	end
	return tmpString;
end

--[[-----------------------------------------------------------------------------
Delay a function
-------------------------------------------------------------------------------]]
local waitTable = {};
local waitFrame = nil;
function addon:FuncDelay(delay, func, ...)
  if(type(delay)~="number" or type(func)~="function") then
    return false;
  end
  if(waitFrame == nil) then
    waitFrame = CreateFrame("Frame","WaitFrame", UIParent);
    waitFrame:SetScript("onUpdate",function (self,elapse)
      local count = #waitTable;
      local i = 1;
      while(i<=count) do
        local waitRecord = tremove(waitTable,i);
        local d = tremove(waitRecord,1);
        local f = tremove(waitRecord,1);
        local p = tremove(waitRecord,1);
        if(d>elapse) then
          tinsert(waitTable,i,{d-elapse,f,p});
          i = i + 1;
        else
          count = count - 1;
          f(unpack(p));
        end
      end
    end);
  end
  tinsert(waitTable,{delay,func,{...}});
  return true;
end

--[[-----------------------------------------------------------------------------
Blizzard Build comparisonn for ptr/beta/live compatible versions
-------------------------------------------------------------------------------]]
function addon:CompareBuild(comver, combuild, comref, lowcomref, highcomref)
	local version, build, bdate, toc = GetBuildInfo()
	if version > comver and build > combuild then
		addon[highcomref]()
	elseif version < comver and build < combuild then
		addon[lowcomref]()
	elseif version == comver and build == combuild then
		addon[comref]()
	end
end

--[[-----------------------------------------------------------------------------
Reload Frame
-------------------------------------------------------------------------------]]
function addon:OpenReloadFrame(myfunc)
	local reloadFrame
	if(reloadFrame) then
		return reloadFrame:Show()
	end

	reloadFrame = CreateFrame("Frame", nil, UIParent)
	reloadFrame:SetHeight(160)
	reloadFrame:SetWidth(350)
	reloadFrame:SetPoint("CENTER", UIParent, "CENTER", 0, 200)
	reloadFrame:SetBackdrop{
		bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background",
		edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border",
		tile = true,
		tileSize = 32,
		edgeSize = 32,
		insets = {
			left = 11,
			right = 12,
			top = 12,
			bottom = 11
		}
	}

	local text = reloadFrame:CreateFontString(nil, "ARTWORK", "GameFontNormalHuge")
	text:SetText("GrimUI: Reload")
	text:SetPoint("TOP", 0, -20)

	local text2 = reloadFrame:CreateFontString(nil, "ARTWORK", "GameFontHighlight")
	text2:SetText("GrimUI requires a reload\n to finish its configuration.")
	text2:SetPoint("TOP", 0, -60)

	local button1 = CreateFrame("Button", "okay", reloadFrame, "UIPanelButtonTemplate")
	button1:SetHeight(45)
	button1:SetWidth(125)
	button1:SetPoint("BOTTOMLEFT", 15, 15)
	button1:SetText("Reload")
	button1:RegisterForClicks("AnyUp")
	button1:SetScript("OnClick", myfunc)

	local button2 = CreateFrame("Button", "cancel", reloadFrame, "UIPanelButtonTemplate")
	button2:SetHeight(45)
	button2:SetWidth(125)
	button2:SetPoint("BOTTOMRIGHT", -15, 15)
	button2:SetText("Cancel")
	button2:RegisterForClicks("AnyUp")
	button2:SetScript("OnClick", function() reloadFrame:Hide() end)
end

--[[-----------------------------------------------------------------------------
LibSharedMedia support
-------------------------------------------------------------------------------]]
local LSM = LibStub('LibSharedMedia-3.0')
LSM:Register('background', addonName, [[Interface\Addons\]] .. addonName .. [[\Media\MainBG]])
LSM:Register('font', "Franklin Gothing Medium", [[Interface\Addons\]] .. addonName .. [[\Media\Font1.ttf]])
LSM:Register('font', "Comic Sans MS", [[Interface\Addons\]] .. addonName .. [[\Media\Font3.ttf]])

--[[-----------------------------------------------------------------------------
Localization support. AceLocale
-------------------------------------------------------------------------------]]
local AceLocale = LibStub("AceLocale-3.0")
local L = AceLocale:GetLocale( "GrimUI", true )
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
01-31-12, 05:24 PM   #22
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,691
Originally Posted by Grimsin View Post
Neither of the or'ing methods work it always trys to hook to the first frame passed and when it finds its not a frame it errors.

doing a frame =~ nil did work
Then you asked the wrong question. You asked if a frame had been created yet. If a frame has not been created, then it is nil - assuming that you used a unique name or unique global variable for it. If it is nil, then my line will pass through the or. If, as you say, it throws an error saying that it's not a table, then it's not nil. It's equal to something else. Meaning that you are using the same variable name for multiple things.
__________________
"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
01-31-12, 06:03 PM   #23
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
Originally Posted by Seerah View Post
Then you asked the wrong question. You asked if a frame had been created yet. If a frame has not been created, then it is nil - assuming that you used a unique name or unique global variable for it. If it is nil, then my line will pass through the or. If, as you say, it throws an error saying that it's not a table, then it's not nil. It's equal to something else. Meaning that you are using the same variable name for multiple things.
I dont mean that it finds that its not a frame it tells me that it just does not find it at all period and then it stops the code and shoots an error... ill try it again when i get a chance... the frame ~= nil seems to be working fine

Code:
function addon:ArtSetPoint()
	skin:SetPoint('BOTTOMLEFT', -addon.settings.artSetPoint, 0)
	skin:SetPoint('BOTTOMRIGHT', addon.settings.artSetPoint, 0)
	
	-- The following is done so TargetFrame.lua does not need to load first or at all. 
	if GrimUITargetFrame ~= nil then
		skin[4]:SetParent("GrimUITargetFrame")
		skin[4]:SetPoint('BOTTOM', GrimUITargetFrame, 'BOTTOM', 0, 4)
	end
end
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]

Last edited by Grimsin : 01-31-12 at 06:05 PM.
  Reply With Quote
01-31-12, 07:17 PM   #24
Torhal
A Pyroguard Emberseer
 
Torhal's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 1,196
Originally Posted by Grimsin View Post
How do you do that? Originally my goal was to setup a core file that i could put functions in that would be later used in other files as well as setup a handful of things.
I have my AddOn "core" table, which can be exposed to the world via the global table. Then I use the AddOn-wide table provided by "..." as a private namespace for things I'd rather keep internal but will still be accessible by every file in the AddOn.
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Author of NPCScan and many other AddOns.
  Reply With Quote
01-31-12, 07:38 PM   #25
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 1,877
Originally Posted by Torhal View Post
Including this line, however, is not redundant
The code as posted in its intent, to register the shared table as a global, would be redundant. Reregistering a global multiple times follows the exact definition of redundancy.



Torhol's method of having an addon remain out of the global namespace is a valid approach, although if you have modules loaded as LoD, there isn't any other way around it. Also a global namespace helps with poking around your addon while trying to debug errors.
__________________
ESOUI AddOns | WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 01-31-12 at 07:45 PM.
  Reply With Quote
01-31-12, 10:02 PM   #26
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
Okay i double checked the "or" business and yea you CAN NOT pass a non existent frame through the or statement the way you had suggested. It gives an error that says region unknown and stops. It will not just skip over.

Also... I FOUND THE DC BUG!!! well... what file its in anyhow... i posted relevant code in the other post about it...
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
01-31-12, 10:03 PM   #27
Torhal
A Pyroguard Emberseer
 
Torhal's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 1,196
Originally Posted by SDPhantom View Post
The code as posted in its intent, to register the shared table as a global, would be redundant. Reregistering a global multiple times follows the exact definition of redundancy.
Aye - already said as much.
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Author of NPCScan and many other AddOns.
  Reply With Quote
02-01-12, 05:46 PM   #28
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Grimsin View Post
Okay i double checked the "or" business and yea you CAN NOT pass a non existent frame through the or statement the way you had suggested. It gives an error that says region unknown and stops. It will not just skip over.
I don't know what you're doing, but:

Code:
frame:SetPoint("BOTTOM", otherFrame or UIParent, "CENTER", 0, 100)
has always worked for me, and is actively used in several of my published addons.

If you're seeing an error, in order to tell you why, we need to see both your actual code, and the actual error.
  Reply With Quote
02-01-12, 08:32 PM   #29
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
Originally Posted by Phanx View Post
I don't know what you're doing, but:

Code:
frame:SetPoint("BOTTOM", otherFrame or UIParent, "CENTER", 0, 100)
has always worked for me, and is actively used in several of my published addons.

If you're seeing an error, in order to tell you why, we need to see both your actual code, and the actual error.
On a frame that does not actually exist?
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
02-01-12, 08:37 PM   #30
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,691
I've done the or assignment in the past, too, which is why I said "if, for some reason, this is not working for you then..." Yes, on a frame that doesn't exist. The only way it would move to UIParent (in Phanx's example) is if otherFrame was nil.

We can only help you with an error if we see what the error actually was and the code that triggered it.


/edit: you said that the error mentioned that it wasn't a table. Frames are just special tables. A nil value would have given you a nil error. As I mentioned above, you must be assigning something else to that variable name that isn't a table/frame.
__________________
"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-02-12, 12:46 AM   #31
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
Originally Posted by Seerah View Post
I've done the or assignment in the past, too, which is why I said "if, for some reason, this is not working for you then..." Yes, on a frame that doesn't exist. The only way it would move to UIParent (in Phanx's example) is if otherFrame was nil.

We can only help you with an error if we see what the error actually was and the code that triggered it.


/edit: you said that the error mentioned that it wasn't a table. Frames are just special tables. A nil value would have given you a nil error. As I mentioned above, you must be assigning something else to that variable name that isn't a table/frame.
It did not say that it was an invalid table it said invalid region
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
02-03-12, 03:33 AM   #32
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Grimsin View Post
On a frame that does not actually exist?
Yes. Just now, I typed:

Code:
/dump LOLframe
Verification that no such frame existed was printed to my chat frame:

Dump: LOLframe
LOLframe = nil,
empty result
Then, I typed:

Code:
/run ShieldsUp:ClearAllPoints() ShieldsUp:SetPoint("CENTER", LOLframe or UIParent, "CENTER", 0, 0)
The ShieldsUp frame was correctly moved to the center of the UIParent frame, since there is no such thing as a LOLframe frame.

Then, to try to replicate your error, I typed:

Code:
/run LOLframe = "haha"
Then, I again typed:

Code:
/run ShieldsUp:ClearAllPoints() ShieldsUp:SetPoint("CENTER", LOLframe or UIParent, "CENTER", 0, 0)
This error occurred:

1x <string>:"ShieldsUp:ClearAllPoints() ShieldsUp:SetPoi...":1: <unnamed>:SetPoint(): Couldn"t find region named "haha"
... which sounds very similar to the error you're getting (but for some reason refuse to actually post, despite the fact that this thread would have been over at reply #1 if you had just posted it), which means that Seerah's hunch is correct, and you are trying to position your frame relative to something other than another frame (or frame region, since you can position frames relative to font strings and textures, as well as actual frames).

Most likely, you used the same generic name for both a frame and something else in your code, which is why I always criticize people for using generic names in the code they post. If you use descriptive names, and follow basic naming conventions, you will never have this problem.
  Reply With Quote
02-03-12, 02:11 PM   #33
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
I didnt post the error because it was trivial because doing the nonexistantframe ~= nil worked fine and thinking about it if that is working it says that the frame does = nil so why would it work one way and not the other?? It may be that it works for the setpoint and not the setparent or something. But i didnt post the error because i moved over the issue it was trivial to my goal at the time which was tracking down the dc bug... theres plenty of other issues in the code im working on naming everything more specifically as we type. There are issues now with the saved variable functions and im getting tons of errors claiming it cant find my variables so who knows what happened. One thing at a time...
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
02-03-12, 02:59 PM   #34
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 1,877
frame:SetPoint() has some quirks about the frame argument, if it's a string, it references by the frame by name. If it's a table (the reference of the UI object is stored as a userdata in index zero), it tries to use it as the frame directly. If it's nil, it references the screen itself.
__________________
ESOUI AddOns | WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 02-03-12 at 03:55 PM.
  Reply With Quote
02-03-12, 03:32 PM   #35
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,691
nonexistantframe ~= nil worked fine and thinking about it if that is working it says that the frame does = nil
No, that says that the frame does not = nil
__________________
"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-04-12, 10:25 AM   #36
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
Originally Posted by Seerah View Post
No, that says that the frame does not = nil
Yes but in the fashion i have used it... if it works both ways it means it fires right when it does not = nil and fires right when it does = nil. meaning it is nil when i need it to be lol. Like i said it may have just been the setparent that had issues with the or statement. i didnt spend that much time on it.
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
02-04-12, 01:29 PM   #37
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,691
What I meant was that if your variable was assigned but not to a frame, ~=nil would still evaluate to true.
__________________
"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

WoWInterface » Developer Discussions » General Authoring Discussion » a means of checking if a frame exists

Thread Tools
Display Modes

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