View Single Post
06-09-05, 06:51 AM   #5
diiverr
A Theradrim Guardian
AddOn Author - Click to view addons
Join Date: Jan 2005
Posts: 67
[grumble]
While your post makes sense to me, I'm afraid I can't get the syntax correct. Heck, I can't even get the actual value to display in a CHAT_FRAME dump. I can display a message, but nothing productive.

Originally Posted by Gello
On the value not chaning right away: A slider's OnValueChanged will get called BEFORE your variables are loaded. As part of a slider's initialization it will call OnValueChanged. This may be why its last state is not being saved initialially. I don't see a DiivSkins_hbar1Update() but I suspect it's assuming variables are loaded and they're not yet. (and in fact it'd be overwritten by this:GetValue())

How I handle sliders is this:
1. In the mod's initialization, after VARIABLES_LOADED, I slider:SetValue(last position)
2. In the slider's OnValueChanged() function, I check first if the mod is loaded, and if it is, then I assume the current position is valid and work with it from there.

When troubleshooting a sequence of events I'll often pepper my code with a lot of DEFAULT_CHAT_FRAME:AddMessage("In OnValueChange now") and stuff like the above will stand out right away.
What I think is happening is that my savedvariable texture reference, while being saved, is not being called until the slider is visible. I verified this by changing the root textCoord's of the original xml frame, as this frame is not hidden. (I just did something wacky to get a distorted image displayed).

On start up, I get the base (distorted) XML texture. Once I open the slider page, then the frame's SetTexture reference from the slider value is recognized and employed, and all is well. This will persist until reload/relog. Then we start over. The variable is saved, but not displayed, until I access the slider. I don't even need to adjust it, just make it visible on screen by opening its page in my config UI. The moment the slider is displayed on screen, the texture for the frame in question is displayed, correctly, from the saved variable as well.


Could you maybe point me at an AddOn that initializes referencing a Slider Value? I couldn't seem to find one, but maybe looking at how its done might help me. My brain tells me the slider value isn't the problem, but that I'm just not actively displaying the data contained in the SavedVariable on initialization.

I would think just running the update function would accomplish this, but I can't for the life of me get that DiivSkins_hbar1Update() function (posted earlier) to fire from anywhere other than the <OnValueChanged> call of the slider xml.

It always returns a ...attempt to call global ... (a nil value) pertaining to itself if I try to call it from an OnEvent or an OnLoad.
[/grumble]



Thanks in advance for any assistance anyone might be able to give, and for patronizing the unedumaceted.
  Reply With Quote