Thread Tools Display Modes
Prev Previous Post   Next Post Next
08-10-19, 09:21 AM   #1
Sojiro84
Guest
Posts: n/a
Need help loading SavedVariable setting.

I searched around and I have tried a dozen things but somehow, I can't get it to work.
I can get the value 1 or 3 saved, but somewhere with reading it back, it goes wrong but I am unsure why.

Here is the AddOns code:

Code:
WorldMapFrame:SetScale(0.8)
Code:
WorldMapFrame.BlackoutFrame.Blackout:SetAlpha(0)

if SimpleMap == 1 then
    PlayerMovementFrameFader.AddDeferredFrame(WorldMapFrame, .3, 3.0, .5)
elseif SimpleMap == 3 then
    PlayerMovementFrameFader.AddDeferredFrame(WorldMapFrame, 1, 3.0, .5)
end


WorldMapFrame.ScrollContainer.GetCursorPosition = function(f)
    local x,y = MapCanvasScrollControllerMixin.GetCursorPosition(f);
    local s = WorldMapFrame:GetScale();
    return x/s, y/s;
end

local function SimpleMapCommands(msg, editbox)
  if msg == 'off' then
    print('SimpleMap fade has been turned off.')
    PlayerMovementFrameFader.AddDeferredFrame(WorldMapFrame, 1, 3.0, .5)
    SimpleMap = 3
  elseif msg == 'on' then
    print("SimpleMap fade has been turned on.")
    PlayerMovementFrameFader.AddDeferredFrame(WorldMapFrame, .3, 3.0, .5)
    SimpleMap = 1
  end
end


SLASH_SMFADE1 = '/smfade'

SlashCmdList["SMFADE"] = SimpleMapCommands


And here is the .toc.

Code:
## Interface: 11302
## Version: 1.1
## Title: SimpleMap
## Notes: Smaller worldmap and it fades the map when moving
## Author: Sojiro84
## Dependencies: Blizzard_WorldMap
## SavedVariables: SimpleMap

SimpleMap.lua
Code:



The savedvariable contrains either "SimpleMap = 1" or "SimpleMap = 3".

Somehow the following doesn't trigger:

Code:
if SimpleMap == 1 then
    PlayerMovementFrameFader.AddDeferredFrame(WorldMapFrame, .3, 3.0, .5)
elseif SimpleMap == 3 then
    PlayerMovementFrameFader.AddDeferredFrame(WorldMapFrame, 1, 3.0, .5)
end


I tried "AddOn Loaded" events and saying that variable "SimpleMap = SimpleMap" so that the value is loaded but nothing.

Clearly SimpleMap isn't being assigned with the SavedVariable value.

Can anyone help me?

It feels like the solution should be simple but I never made a WoW AddOn before so a bit difficult for me!

Last edited by Sojiro84 : 08-10-19 at 09:25 AM.
  Reply With Quote
 

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Need help loading SavedVariable setting.

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