View Single Post
04-22-10, 03:09 PM   #17
eddiemars
A Cyclonian
 
eddiemars's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 43
Originally Posted by eddiemars View Post
You think if I just set up a saved variables
Wow, okay. Saved Variables making is so confusing! I've followed a couple guides (ie: http://www.wowwiki.com/Saving_variab..._game_sessions) but, none of them explain how to put frame placement info into the savedvariable file. I'm sure it's supposed to be self explanatory but I am very lost. Anyone know a better (or more frame specific) tutorial for this? Or maybe you enjoy helping out nubs, for those of you that do I will include the very bungled .lua I have going on. As it is right now, it just does nothing. If you think the file is a total lost cause by all means don't feel compelled to help out just because I'm asking! I understand! I do however truly appreciate all the help.

Code:
local frame = CreateFrame("Frame", "AsteroidMinimapButtons", UIParent)
frame:RegisterEvent("ADDON_LOADED")
frame:RegisterEvent("PLAYER_LOGOUT")

function frame:OnEvent(event, arg1)
	if event == "ADDON_LOADED" and arg1 == "AsteroidMinimapButtons" then

	 	local kiddies, i = { Minimap:GetChildren() }, 1;
		--remove
		while i <= #kiddies do
			if kiddies[i]:GetName() == "MinimapPing" or kiddies[i]:GetName() == "MinimapBackdrop" or kiddies[i]:GetName() == "AsteroidMinimap" or kiddies[i]:GetName() == "AsteroidFrame" then
				tremove(kiddies,i);
			else
				i=i+1;
			end
		end

		if not AstroDB or AstroDB == nil then
			for _, framex in ipairs(kiddies) do
			DEFAULT_CHAT_FRAME:AddMessage( framex:GetName() )
				framex:RegisterForDrag("LeftButton")
				framex:SetClampedToScreen(true)
				framex:SetMovable(true)
				framex:SetScript("OnDragStart", function(self) if IsAltKeyDown() then self:StartMoving() end end)
				framex:SetScript("OnDragStop", function(self) if IsAltKeyDown() then self:StopMovingOrSizing() end end)
			end
		AstroDB = --??So confused.
		end

		if AstroDB then
			for _, framex in ipairs(kiddies) do
			DEFAULT_CHAT_FRAME:AddMessage( framex:GetName() )
				point, relativeTo, relativePoint, xOfs, yOfs = framex:GetPoint()
				framex:SetPoint(point, relativeTo, relativePoint, xOfs, yOfs)
				framex:RegisterForDrag("LeftButton")
				framex:SetClampedToScreen(true)
				framex:SetMovable(true)
				framex:SetScript("OnDragStart", function(self) if IsAltKeyDown() then self:StartMoving() end end)
				framex:SetScript("OnDragStop", function(self) if IsAltKeyDown() then self:StopMovingOrSizing() end end)
			end
		end

	elseif event == "PLAYER_LOGOUT" then
	 	local kiddies, i = { Minimap:GetChildren() }, 1;
		--remove
		while i <= #kiddies do
			if kiddies[i]:GetName() == "MinimapPing" or kiddies[i]:GetName() == "MinimapBackdrop" or kiddies[i]:GetName() == "AsteroidMinimap" or kiddies[i]:GetName() == "AsteroidFrame" then
				tremove(kiddies,i);
			else
				i=i+1;
			end
		end

		for _, framex in ipairs(kiddies) do
			point, relativeTo, relativePoint, xOfs, yOfs = framex:GetPoint()
		end
	AstroDB = { framex:GetPoint() }--???
	end
end
I tried putting in savedvariable info to my original file, but it never worked that way either, so this version I have linked is the wowwiki tutorial version copy pasted with my own addon's info and desired functions.

Here's the working version without a savedvariables. (Well, sort of working, like I said before the reason I want saved variables is to keep the positions of certain frames that Blizz is overriding like TimeManagerClockButton. Also it loads the function a million times for each Addon, I triesd to add a 'if arg1' deal but I think my SetScript is messy, anyways.)

Code:
local AMwait = CreateFrame("Frame","AMWaitFrame", UIParent)

local event = function (self)
	local kiddies, i = { Minimap:GetChildren() }, 1;
	--remove
	while i <= #kiddies do
		if kiddies[i]:GetName() == "MinimapPing" or kiddies[i]:GetName() == "MinimapBackdrop" or kiddies[i]:GetName() == "AsteroidMinimap" or kiddies[i]:GetName() == "AsteroidFrame" then
			tremove(kiddies,i);
		else
			i=i+1;
		end
	end

	for _, framex in ipairs(kiddies) do
	 DEFAULT_CHAT_FRAME:AddMessage( framex:GetName() )
		 framex:RegisterForDrag("LeftButton")
		 framex:SetClampedToScreen(true)
		 framex:SetMovable(true)
		 framex:SetScript("OnDragStart", function(self) if IsAltKeyDown() then self:StartMoving() end end)
		 framex:SetScript("OnDragStop", function(self) if IsAltKeyDown() then self:StopMovingOrSizing() end end)
	end
end

AMwait:SetScript("OnEvent", event)
AMwait:RegisterEvent"ADDON_LOADED"
__________________
MAGICAL CRAWDAD APPROVED:
  Reply With Quote