View Single Post
12-10-05, 12:49 PM   #2
Gello
A Molten Giant
AddOn Author - Click to view addons
Join Date: Jan 2005
Posts: 521
<OnValueChanged> is called when the slider is loaded (the OnLoad is also). This happens before VARIABLES_LOADED. In the VARIABLES_LOADED or beyond you'll want to :SetValue. Are you able to MySlider1:SetValue(.5) to get it to work? At a glance I don't see anything wrong.

Btw, it takes less lines of code and imho improves the professionalism of a mod a great deal to make the minimap button draggable instead of a slider buried in options somewhere:

In addition to your minimap button's frame, make one frame devoted to an OnUpdate that's always hidden:

<Button name="MyMinimapButton">
<Scripts>
<OnLoad>
this:RegisterForDrag("LeftButton")
</OnLoad>
<OnDragStart>
this:LockHighlight()
MyMod_IconDraggingFrame:Show()
</OnDragStart>
<OnDragStop>
this:UnlockHighlight()
MyMod_IconDraggingFrame:Hide()
</OnDragStop>
</Button>

<Frame name="MyMod_IconDraggingFrame" hidden="true">
<Scripts>
<OnUpdate>
local xpos,ypos = GetCursorPosition()
local xmin,ymin = Minimap:GetLeft(), Minimap:GetBottom()
xpos = xmin-xpos/UIParent:GetScale()+70
ypos = ypos/UIParent:GetScale()-ymin-70
MySettings.IconPosition = math.deg(math.atan2(ypos,xpos))
MyMinimapButton:SetPoint("TOPLEFT","Minimap","TOPLEFT",52-(80*cos(MySettings.IconPosition or 45)),(80*sin(MySettings.IconPosition or 45))-52)
</OnUpdate>
</Scripts>
</Frame>

I usually put that last line in the OnUpdate into a local function move_icon, and call it after VARIABLES_LOADED and from within the OnUpdate. (tho of course the OnUpdate code is moved over to the lua file to call a local function made in lua file) No fuss movable minimap buttons that clings to the minimap edge as you drag it around.

Last edited by Gello : 12-10-05 at 12:54 PM.
  Reply With Quote