WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   SetScale (https://www.wowinterface.com/forums/showthread.php?t=32767)

Ferous 05-26-10 11:45 PM

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

Freebaser 05-27-10 12:16 AM

Minimap:SetResizable(true) isn't doing anything if its inside that slash cmd when the ui is loading.

Ferous 05-27-10 12:52 AM

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

Xrystal 05-27-10 12:54 AM

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 ?

Ferous 05-27-10 12:59 AM

Quote:

Originally Posted by Xrystal (Post 189697)
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.

Xrystal 05-27-10 01:16 AM

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.

Ferous 05-27-10 01:21 AM

Alrighty, i will try to work it out and see what I come up with, thank you :)

Referring to this:

Quote:

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

Xrystal 05-27-10 01:27 AM

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.

Ferous 05-27-10 01:30 AM

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

Xrystal 05-27-10 01:34 AM

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 :D 2 or 3 extra lines and you'll be set :D

Ferous 05-27-10 01:36 AM

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.

Ferous 05-27-10 02:26 AM

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

Freebaser 05-27-10 07:13 AM

Quote:

Originally Posted by Ferous (Post 189713)
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?

nightcracker 05-27-10 09:41 AM

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)


Ferous 05-27-10 10:28 AM

Quote:

Originally Posted by Freebaser (Post 189755)
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 :)

Quote:

Originally Posted by nightcracker (Post 189775)
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 :)

Ferous 05-27-10 10:46 AM

Quote:

Originally Posted by nightcracker (Post 189775)
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.

Soulofsin_007 05-27-10 10:57 AM

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.

Ferous 05-27-10 12:28 PM

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 = #'

Xrystal 05-27-10 02:07 PM

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

Ferous 05-27-10 02:18 PM

Quote:

Originally Posted by Xrystal (Post 189813)
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 :D

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)

Quote:

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


All times are GMT -6. The time now is 07:36 PM.

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