Thread Tools Display Modes
05-26-10, 11:45 PM   #1
Ferous
Sheer Sense of Doom
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 863
SetScale

Hello there! I am here to bug you all again! Mwahahhahahah! Welll.. I wouldn't make a new thread if I didn't need help and I need help if it is available at all.

I have this script below:

Code:
SLASH_MYSCRIPT1 = "/scale";
SlashCmdList["MYSCRIPT"] = function(cmd)
	Minimap:SetScale(tonumber(cmd))
	Minimap:SetResizable(true)
end
And it allows my minimap to be scaled ingame, however it ain't saving the scale after logout or reload and I assumed that the script

Code:
Minimap:SetResizable(true)
Made it to where it saves the size much like:

Code:
Minimap:SetUserPlaced(true)
And was curious why it ain't saving?

Any help is appreciated and thank you for your time!
  Reply With Quote
05-27-10, 12:16 AM   #2
Freebaser
A Molten Kobold Bandit
 
Freebaser's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2008
Posts: 135
Minimap:SetResizable(true) isn't doing anything if its inside that slash cmd when the ui is loading.
  Reply With Quote
05-27-10, 12:52 AM   #3
Ferous
Sheer Sense of Doom
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 863
yeah I took it out :P But it still ain't saving.. I am still playing with it :P My brain hurts >.>

here is everything if anyone is curious.

http://pastie.org/979464

Maybe I messed up somewhere.. I wish I could see it :P

Last edited by Ferous : 05-27-10 at 12:58 AM.
  Reply With Quote
05-27-10, 12:54 AM   #4
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,877
When you say it isn't saving are you checking the WTF file to see if it is physically saving and not using what was saved or is it actually not saving to the file ?
__________________
  Reply With Quote
05-27-10, 12:59 AM   #5
Ferous
Sheer Sense of Doom
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 863
Originally Posted by Xrystal View Post
When you say it isn't saving are you checking the WTF file to see if it is physically saving and not using what was saved or is it actually not saving to the file ?
It's not saving the minimap scale between loading of screen or log out, player login, etc.

Do I have to used saved variables for that? >.>

I'm thinking I do, but if I really do have to use saved variables, is there a reference anywhere that could possibly help me out adding saved variables? I've been looking at past threads, but some are very old and I don't know if that is a good reference or not.
  Reply With Quote
05-27-10, 01:16 AM   #6
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,877
I'm not sure if blizzard saves scaling settings in its auto save files.

I know it stores the position and sizing although not always the position and size you were planning on rofl. The blizzard cvars and saved variables are loaded with VARIABLES_LOADED or rather that event is triggered once they have finished their stuff rofl.

You could use that to see if frame:GetScale() returns what you initially used frame:SetScale() with. That would the first step to see if it ignores the scaling you did or if it deals with it but does something different rofl.

As to using your own SavedVariables. wowwiki is a good resource for that. This page may help you figure that stuff out if it works out that you need to use it : http://www.wowwiki.com/Saving_variab..._game_sessions

Also, on a side note, from what I found out while playing with the watch frame positioning and sizing etc there is a file called layout-local.txt in your characters wtf folder that seems to be where they store the individual layout of some but not all frames.

Ah, here it is. The frame layouts stored there seem to be done if you use the function http://www.wowwiki.com/API_Frame_SetUserPlaced and there are a few key conditions that you might want to see if that could be why it doesn't work for you.

However, like I said, I doubt that it stores the scaling. Here is an example of one of the frames for one of my characters:

Frame: MinimapCluster
FrameLevel: 6
Anchor: BOTTOM
X: -6
Y: 30
W: 192
H: 192

A quick search for scale and a scan for anything that could mean scale found nothing in the file.

So worst case scenario you will need to store and restore the scaling.
__________________
  Reply With Quote
05-27-10, 01:21 AM   #7
Ferous
Sheer Sense of Doom
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 863
Alrighty, i will try to work it out and see what I come up with, thank you

Referring to this:

So worst case scenario you will need to store and restore the scaling.
What do you mean by that? :O Sorry to bug you :P
  Reply With Quote
05-27-10, 01:27 AM   #8
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,877
I just meant that if, as I suspect and you are starting to suspect, it isn't self saving the scale that you may have delve into the nitty gritty details of saving them in savedvariables file.
__________________
  Reply With Quote
05-27-10, 01:30 AM   #9
Ferous
Sheer Sense of Doom
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 863
Ah okay. Well, I have that slash command so people can change the scale, so I was thinking, how would I get that to save in the future, if I did add scale manually, and have it save in the future? Or me adding it in the saved variables, it would just save in the future? :P

edit - I don't know if that made any sense lol
  Reply With Quote
05-27-10, 01:34 AM   #10
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,877
Rofl. You will not believe how easy it will be to save your variables. If you have ever used tables you're half way there. Take a quick gander at that page I linked when you're head is more level rofl and you will see what I mean.

Basically your code as it is will work fine. You just need to store the value in your saved variable table and restore it when your addon starts 2 or 3 extra lines and you'll be set
__________________
  Reply With Quote
05-27-10, 01:36 AM   #11
Ferous
Sheer Sense of Doom
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 863
Hmmmmmm I changed the scale in the saved variables but it was set to nil. So what I did was, set the scale to 3 ingame, then reloaded, and then it was set back to nil... Hmm hmmhmm lol Sorry I'm still learning, but at least its saving now.

I see what you wrote above :P I will continue to work on it.

Last edited by Ferous : 05-27-10 at 01:38 AM.
  Reply With Quote
05-27-10, 02:26 AM   #12
Ferous
Sheer Sense of Doom
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 863
Well... I think I will try tomorrow

I did add the whole table, saved variables, the whole thing, still not saving. Even manually added the scale in the saved variables, still not saving scale...

I will have to wait till tomorrow. For now, bed time >.>
  Reply With Quote
05-27-10, 07:13 AM   #13
Freebaser
A Molten Kobold Bandit
 
Freebaser's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2008
Posts: 135
Originally Posted by Ferous View Post
Well... I think I will try tomorrow

I did add the whole table, saved variables, the whole thing, still not saving. Even manually added the scale in the saved variables, still not saving scale...

I will have to wait till tomorrow. For now, bed time >.>
Look at itsymm, It is a minimal minimap that does what your looking for.

Edit: Also, did you add SavedVariables to your .toc?

Last edited by Freebaser : 05-27-10 at 07:15 AM.
  Reply With Quote
05-27-10, 09:41 AM   #14
nightcracker
A Molten Giant
 
nightcracker's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 716
Simple.

Add this to the .toc file:
Code:
##SavedVariables: FerousMinimapScale
And this to the top of the .lua file:
Code:
local addon = ...

SLASH_MYSCRIPT1 = "/scale";
SlashCmdList["MYSCRIPT"] = function(cmd)
	if not tonumber(cmd) then return end
	Minimap:SetScale(tonumber(cmd))
	FerousMinimapScale = tonumber(cmd)
end

local holder = CreateFrame("Frame")
holder:RegisterEvent("ADDON_LOADED")
holder:SetScript("OnEvent", function(self, arg1)
	if arg1~=addon then return end
	FerousMinimapScale = FerousMinimapScale or Minimap:GetScale()
	Minimap:SetResizable(true)
	Minimap:SetScale(FerousMinimapScale)
end)
__________________
Three things are certain,
Death, taxes and site not found,
You, victim of one.
  Reply With Quote
05-27-10, 10:28 AM   #15
Ferous
Sheer Sense of Doom
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 863
Originally Posted by Freebaser View Post
Look at itsymm, It is a minimal minimap that does what your looking for.

Edit: Also, did you add SavedVariables to your .toc?
Mhmm, Yes I did :P I will take a look at itsymm and check it out. Thank you

Originally Posted by nightcracker View Post
Simple.

Add this to the .toc file:
Code:
##SavedVariables: FerousMinimapScale
And this to the top of the .lua file:
Code:
local addon = ...

SLASH_MYSCRIPT1 = "/scale";
SlashCmdList["MYSCRIPT"] = function(cmd)
	if not tonumber(cmd) then return end
	Minimap:SetScale(tonumber(cmd))
	FerousMinimapScale = tonumber(cmd)
end

local holder = CreateFrame("Frame")
holder:RegisterEvent("ADDON_LOADED")
holder:SetScript("OnEvent", function(self, arg1)
	if arg1~=addon then return end
	FerousMinimapScale = FerousMinimapScale or Minimap:GetScale()
	Minimap:SetResizable(true)
	Minimap:SetScale(FerousMinimapScale)
end)
^Above, i will try it out. Thanks.

edit - i want to say thank you to everyone who has helped thus far, I am still new to coding, but I'm finally getting the hang of it with no lua experience lol so thanks again everyone
  Reply With Quote
05-27-10, 10:46 AM   #16
Ferous
Sheer Sense of Doom
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 863
Originally Posted by nightcracker View Post
Simple.

Add this to the .toc file:
Code:
##SavedVariables: FerousMinimapScale
And this to the top of the .lua file:
Code:
local addon = ...

SLASH_MYSCRIPT1 = "/scale";
SlashCmdList["MYSCRIPT"] = function(cmd)
	if not tonumber(cmd) then return end
	Minimap:SetScale(tonumber(cmd))
	FerousMinimapScale = tonumber(cmd)
end

local holder = CreateFrame("Frame")
holder:RegisterEvent("ADDON_LOADED")
holder:SetScript("OnEvent", function(self, arg1)
	if arg1~=addon then return end
	FerousMinimapScale = FerousMinimapScale or Minimap:GetScale()
	Minimap:SetResizable(true)
	Minimap:SetScale(FerousMinimapScale)
end)
Well.. I did all that Nightcracker, still ain't saving scale >.> i will continue to mess with it.
  Reply With Quote
05-27-10, 10:57 AM   #17
Soulofsin_007
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 125
I dunno if the same concept applies, but when I was creating my pet bar exp addon, or any addon that I had to set scale of the bar this was how I did it.

Code:
MyOptions = {

scale = 1

};

SLASH_SCALE1, SLASH_SCALE2 = '/scale', '/s';
function SlashCmdList.SCALE(msg)
    if(msg == "0.1") then
      print("Setting scale to 0.1")
      Minimap:SetScale(0.1)
      MyOptions.scale = 0.1
    else
     --
end

Frame = CreateFrame("Frame")
Frame:SetScale(MyOptions.scale)
Also MyOptions has to be added to your saved variables to.
  Reply With Quote
05-27-10, 12:28 PM   #18
Ferous
Sheer Sense of Doom
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 863
Okay, I put in what you wrote Nightcracker and it's saving now. I'm extremely close.. But, its just saving as MidgetMapDB = 0.5 or what ever scale I set it to ingame, its not saving it as 'scale = #'
  Reply With Quote
05-27-10, 02:07 PM   #19
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,877
Just change MidgetMapDB to whatever name you want to save it with .. just change it to the same in the TOC as well as your LUA file
__________________
  Reply With Quote
05-27-10, 02:18 PM   #20
Ferous
Sheer Sense of Doom
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 863
Originally Posted by Xrystal View Post
Just change MidgetMapDB to whatever name you want to save it with .. just change it to the same in the TOC as well as your LUA file
yeah I did that:P here is what I got...

Code:
local defaults = { 
align = "TOPRIGHT", 
x = -25, 
y = -25, 
scale = 0.9
 }

local addon = ...

SLASH_MYSCRIPT1 = "/scale";
SlashCmdList["MYSCRIPT"] = function(cmd)
	if not tonumber(cmd) then return end
	Minimap:SetScale(tonumber(cmd))
	MidgetMapDB = { scale = tonumber(cmd) }
end

local MidgetMap = CreateFrame("Frame")
MidgetMap:RegisterEvent("ADDON_LOADED")
MidgetMap:SetScript("OnEvent", function(self, arg1)
	if arg1~=addon then return end
	Minimap:SetResizable(true)
	MidgetMap = Minimap.SetScale
	Minimap:SetScale(MidgetMapDB.scale)
end)
Now, I know I'm doing something wrong, or something here ain't adding up.

it's saving in the saved variables as... (Yes, it is saving when I change scale ingame, but to this)

MidgetMapDB = {
["scale"] = 0.7,
}
I'm trying to figure out why the scale is quoted and bracketed.. I know its something in the code that I messed up or is messing up. This was NightCrackers code that I used as well, and for some reason.. It aint saving without quotes and brackets :P

I'm getting there, I'm getting there.

edit - I also figure, with all my noobish mistakes, this might help someone in the future, so I figured I'd keep going :P lol

Last edited by Ferous : 05-27-10 at 02:20 PM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » SetScale

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