Thread Tools Display Modes
07-18-10, 12:57 AM   #1
Ferous
Sheer Sense of Doom
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 863
Saving Minimap Shape

I figured I would make this post, considering I couldn't find anything on it, and well, it might be useful for others!

I can't get my minimap shape to save. It doesn't save when I log in or out. I got everything else to save, but the shape, and I don't know what to tell it to do in order for it to save...

What would I put into my db?

Example of my db:

Code:
local defaults = { 
align = "TOPRIGHT", 
x = -25, 
y = -25, 
scale = 0.8, 
locked = true,
shape = "SQUARE"
}

Minimap:SetPoint(defaults.align, UIParent, db.align, db.x, db.y)
Minimap:SetScale(defaults.scale)
What would I put for the shape for it to save?

Code:
function GetMinimapShape() return (defaults.shape) end
Also in my slash command, example

Code:
if msg == "round" then
	Minimap:SetMaskTexture"Interface\\AddOns\\MidgetMap\\media\\circlemask"
	function GetMinimapShape() return "ROUND" end
	db.shape = GetMinimapShape()
end
Would I put in above db.shape = GetMinimapShape()?

I know alot of questions

So far I have above but its not saving. I tried to use reference, but I am unable to find reference for shape. Any help is appreciated! Thanks
  Reply With Quote
07-18-10, 01:34 AM   #2
Elhana
A Wyrmkin Dreamwalker
AddOn Author - Click to view addons
Join Date: Jul 2007
Posts: 51
You just make things over complicated for yourself:

Code:
if msg == "round" then
	Minimap:SetMaskTexture"Interface\\AddOns\\MidgetMap\\media\\circlemask"
	db.shape = "ROUND"
end
and replace your "= GetMinimapShape()" with "= db.shape".

There is no real reason to have a function returning value of a variable already available to an addon unless it is out of scope.
If you insist on having that function - don't redefine it on runtime, make SetMinimapShape instead
Code:
function SetMinimapShape(newshape) defaults.shape = newshape end
and use it SetMinimapShape("ROUND")

ps. /calendar is already set in game to show calendar without any addons, surprise! )

Last edited by Elhana : 07-18-10 at 01:41 AM. Reason: ps
  Reply With Quote
07-18-10, 02:34 AM   #3
Ferous
Sheer Sense of Doom
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 863
Originally Posted by Elhana View Post
You just make things over complicated for yourself:

Code:
if msg == "round" then
	Minimap:SetMaskTexture"Interface\\AddOns\\MidgetMap\\media\\circlemask"
	db.shape = "ROUND"
end
and replace your "= GetMinimapShape()" with "= db.shape".

There is no real reason to have a function returning value of a variable already available to an addon unless it is out of scope.
If you insist on having that function - don't redefine it on runtime, make SetMinimapShape instead
Code:
function SetMinimapShape(newshape) defaults.shape = newshape end
and use it SetMinimapShape("ROUND")

ps. /calendar is already set in game to show calendar without any addons, surprise! )
boo i didn't know about the cal thingy lol i've had addons too long. thank you! I will try this out and report! Thanks!
  Reply With Quote
07-18-10, 04:51 PM   #4
Ferous
Sheer Sense of Doom
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 863
What you had told me about the MinimapCluster user placed true worked for the lua errors, though I still can't seem to get it saved, though I understand what to do, its something extremely tiny I'm NOT doing and I know i'm having a retard moment (haven't had any coffee)

I have this so far, I'm going to post a pastie since theres too much things i'll most likely leave out, if not, thanks for the help thus far!

http://pastie.org/1049790

edit - Saved Variables are saving as well.

MidgetMapDB = {
["y"] = -9.999995572791137,
["x"] = -8.750362439560012,
["scale"] = 0.8,
["align"] = "TOPRIGHT",
["locked"] = true,
["shape"] = "ROUND",
["ver"] = 1.4,
}


When I change to square it changes accordingly.

Last edited by Ferous : 07-18-10 at 04:57 PM.
  Reply With Quote
07-18-10, 06:02 PM   #5
Dainton
A Flamescale Wyrmkin
 
Dainton's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2008
Posts: 115
I don't think that SetMinimapShape() actually works. You have to do the whole
Code:
function GetMinimapShape() return "SQUARE" end
thang.

The GetMinimapShape is just for minimap icons. Minimap:SetMaskTexture is the business end. You can use the default "textures\\MinimapMask" for the round mask instead of using your own (unless your round one isn't actually round).

Maybe something like this on load
Code:
if db.shape == "SQUARE" then
	mask = "Interface\\Buttons\\WHITE8X8"
elseif db.shape == "ROUND" then
	mask = "textures\\MinimapMask"
end
Minimap:SetMaskTexture(mask)
And then use this for the slash
Code:
SlashCmdList["SHAPE"] = function(msg)
	local msg = strlower(msg)
	
	if msg == "square" then
		Minimap:SetMaskTexture("Interface\\Buttons\\WHITE8X8")
		db.shape = "SQUARE"
		print(shit.."|cff00ff00: Set to Square.|cff00ff00")
	elseif msg == "round" then
		Minimap:SetMaskTexture("textures\\MinimapMask")
		db.shape = "ROUND"
		print(shit.."|cff00ff00: Set to Round.|cff00ff00")
	else
		print(shit.."|cff00ff00: Type /shape round or square to change the shape|cff00ff00")
	end
end
SLASH_SHAPE1 = "/shape"
I don't know too much about saved variables, but perhaps just having this at the end would suffice
Code:
function GetMinimapShape() return db.shape end

Last edited by Dainton : 07-18-10 at 06:39 PM.
  Reply With Quote
07-18-10, 06:52 PM   #6
Ferous
Sheer Sense of Doom
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 863
That is exactly where I was stuck on thank you I'll try that out.
  Reply With Quote
07-18-10, 06:55 PM   #7
Dainton
A Flamescale Wyrmkin
 
Dainton's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2008
Posts: 115
http://pastie.org/1049884
^ Changes from above. I haven't tested any of this.
  Reply With Quote
07-18-10, 07:09 PM   #8
Ferous
Sheer Sense of Doom
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 863
The stuff you edited worked great! However... it's still not saving between logouts and logins, only between reloads. I have no idea how to get the saved variables to save between sessions :P I don't know much about saved variables myself.
  Reply With Quote
07-18-10, 07:18 PM   #9
Ferous
Sheer Sense of Doom
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 863
Originally Posted by Dainton View Post
http://pastie.org/1049884
^ Changes from above. I haven't tested any of this.
This works yes! Thank you Dainton Thank you very much! It seems putting:
Code:
function GetMinimapShape() return db.shape end
did it very well! Thank you again. I wasn't sure where to put this, or where to have it called at, as Im not very good with saved variables, thanks again!

Also, I loved the big lebowski, love your avatar.
  Reply With Quote
07-18-10, 07:22 PM   #10
Dainton
A Flamescale Wyrmkin
 
Dainton's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2008
Posts: 115
So it's saving between sessions now?
  Reply With Quote
07-18-10, 07:27 PM   #11
Ferous
Sheer Sense of Doom
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 863
Originally Posted by Dainton View Post
So it's saving between sessions now?
Yes it is Its because i put that function at the end instead of in the onevent where it was the whole darned time I knew it wasn't saving for that reason, but i wasn't sure where to place that function

Code:
function GetMinimapShape() return db.shape end
So yes it is now saving between sessions thanks! <3
  Reply With Quote
07-18-10, 10:11 PM   #12
Dainton
A Flamescale Wyrmkin
 
Dainton's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2008
Posts: 115
Awesome! I'm glad it works.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Saving Minimap Shape


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