Thread Tools Display Modes
05-27-10, 02:22 PM   #21
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,877
No, thats working correctly. If I remember rightly table.variable is the same as table[variable] and table["variable"] if dealing with a simple text string.

In your case you could do any of the following and get the same value:

MidgetMapDB.scale
MidgetMapDB["scale"]

or if you store the keyname as a variable
scaleKey = "scale"
MidgetMapDB[scalekey]
__________________
  Reply With Quote
05-27-10, 02:35 PM   #22
Ferous
Sheer Sense of Doom
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 863
Code:
SLASH_MYSCRIPT1 = "/scale";
SlashCmdList["MYSCRIPT"] = function(cmd)
	if not tonumber(cmd) then return end
	Minimap:SetScale(tonumber(cmd))
	MidgetMapDB.scale = tonumber(cmd)
end
yeah I got that down and it saves the scale in, when I type a new scale

Code:
MidgetMapDB = {
	["scale"] = 0.8,
}

But, its not saving the scale ingame >.> I have no idea why. Hmm. It could be something else, let me see lol
  Reply With Quote
05-27-10, 02:44 PM   #23
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,877
What do you mean save while in game ?


Once you set MidgetMapDB.scale or MidgetMapDB["scale"] to the scale you want it is accessible anywhere as MidgetMapDB is your global saved variables table.

Hmm, looking at your code it should work fine. When you first log in it rescales using your newly loaded scale. That works right ?

And then when you use the slash command to change the scale you rescale the frame again. Does that work right ?

Give some examples of what you are doing what scales you are using and when and what the affect is on the frame you are trying to scale and what you were expecting it to do. That might help shed some light as to why it isn't working the way you are expecting.
__________________
  Reply With Quote
05-27-10, 02:45 PM   #24
Ferous
Sheer Sense of Doom
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 863
Okay. I got the saved variables working then.

But, I think the issue this whole time was, its not recognizing midgetmapdb to be controlling the minimap's scale for some reason. i wll have to look into it :P

Thank you to everyone that helped.
  Reply With Quote
05-27-10, 02:46 PM   #25
Ferous
Sheer Sense of Doom
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 863
Originally Posted by Xrystal View Post
What do you mean save while in game ?


Once you set MidgetMapDB.scale or MidgetMapDB["scale"] to the scale you want it is accessible anywhere as MidgetMapDB is your global saved variables table.

Hmm, looking at your code it should work fine. When you first log in it rescales using your newly loaded scale. That works right ?

And then when you use the slash command to change the scale you rescale the frame again. Does that work right ?

Give some examples of what you are doing what scales you are using and when and what the affect is on the frame you are trying to scale and what you were expecting it to do. That might help shed some light as to why it isn't working the way you are expecting.

I just saw what you wrote :P

Its not saving the scale between reloads or logging in and out. Its saving it in the saved variables, from what I'm looking at, when I open it up, but its not saving the scale to the actual minimap upon logging in and out or reloading the game.

When I use the slash command, it does rescale it, but when I go to do a reload, it goes back to default size.

edit - Like if I type ingame /scale 0.5 it will change the saved variables accordingly, and also change the minimap size ingame, but after reload it goes back to defaults.

Last edited by Ferous : 05-27-10 at 02:51 PM.
  Reply With Quote
05-27-10, 02:49 PM   #26
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
What does your block of code look like now (for when you set the scale for the first time)?
__________________
"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
05-27-10, 02:54 PM   #27
Ferous
Sheer Sense of Doom
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 863
See seerah, that is what I'm stuck on now that I actually look and realize that. What would I put for scale? Poop, I feel sort of stupid :P

I know what to put for scale, but if I'm changing it with the slash command, I'm sort of befounded by what i would put for scale in the lua :P ... Going to look at something real fast lol but in the meantime, if you're curious, I guess I can put up a pastie of it. lol I feel stupid :P

http://pastie.org/980773

note the scale on top ain't there no more. the local scale
  Reply With Quote
05-27-10, 03:02 PM   #28
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
You have two "OnEvent" script handlers. The first is being overwritten by the second. (That's the *main* problem.)
__________________
"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
05-27-10, 03:04 PM   #29
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,877
Hmm well I can see that this is glaring at me

Code:
MidgetMap:SetScript("OnEvent", function(self, arg1)
	if arg1~=MidgetMap then return end
	Minimap:SetResizable(true)
	MidgetMapDB = Minimap.scale
	Minimap:SetScale(MidgetMapDB.scale)
end)
By setting MidgetMapDB to Minimap.scale you are overwriting the stored scale value.

Code:
MidgetMap:SetScript("OnEvent", function(self, arg1)
	if arg1~=MidgetMap then return end
	Minimap:SetResizable(true)
	Minimap:SetScale(MidgetMapDB.scale)
end)
That should work fine right there.

Also, at the top of the lua somewhere it might be a good idea to set a default value for the MidgetMapDB scale so that it will use that if nothing has been written to the saved variables file yet.

Code:
MidgetMapDB = {}
MidgetMapDB.scale = 0.9
This will create a default saved variables table that will then get replaced by the saved one once it is loaded. if one doesn't exist it will use these values.

Edit: And what Seerah said .. rofl
__________________
  Reply With Quote
05-27-10, 03:35 PM   #30
Ferous
Sheer Sense of Doom
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 863
You have two "OnEvent" script handlers. The first is being overwritten by the second. (That's the *main* problem.)
>.>

I'll get back to this.. If something else arises lol. Otherwise, it's on my end :P
  Reply With Quote
05-27-10, 09:06 PM   #31
Torhal
A Pyroguard Emberseer
 
Torhal's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 1,196
Originally Posted by Ferous View Post
<snip>I'm trying to figure out why the scale is quoted and bracketed..<snip>
Because that's Lua syntax, which SavedVariables are saved in. This is not a problem.

Code:
MidgetMapDB = {
        ["scale"] = 0.7,
}
This means the table named MidgetMapDB has a member whose key is "scale" with a value of 0.7 - in your code, simply refer to it as such:

Code:
local db = MidgetMapDB

if db.scale == 0.7 then
        print("Yay.")
end

EDIT: Meh. I need to learn to look to see if there are other messages in the thread before replying.
__________________
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.

Last edited by Torhal : 05-27-10 at 09:19 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