Go to Page... |
Thread Tools | Display Modes |
11-01-10, 02:11 PM | #1 |
saving tables as variables in the saved variables
Why is it exactly that when i try to dump a table to the saved variables it only picks up some of the table entry's?
|
|
11-01-10, 02:55 PM | #2 |
well make sure its saving correctly
in your toc you need ##SavedVariables: or ##SavedVariablesPerCharacter: and you dont have to save them, they are just active you could have a addon that said Code:
if event == "VARIABLES_LOADED" then myAddonDB.timesLoggedIn = myAddonDB.timesLoggedIn + 1 end also make sure that you know that Code:
local table1, table2 = {1,2,3}, {4,5,6} table1 = table2 wipe(table2) for k,v in ipairs(table1) do print(k,v) end Another thing is that your saved variables dont have to be tables, you could have MyAddonTimesLogged, MyAddonTimesDied and just have 2 numeric values.
__________________
Chat Consolidate is the solution to any out of control trade chat. Ignore lines, throttle chat, consolidate posts!Follow the link to find out how! ▲ ▲ ▲ WoWInterface wont let me triforce >.> |
|
11-01-10, 03:11 PM | #3 |
Well what im trying to do is... i have a chunk of code that deals with moving frames. It used to just build a table when the game loaded and those were your moveable frames. well... im trying to make things so that i can add/remove frames to that table from in game and have it save my additions/removels per session. I added another savevar to the .toc called GMoveableFrames. I tried to switch everything from that table to the saved variables but the big problem is on log out it only writes half of the frames it should to the saved variable file so on the next load up it does not load all the frames it should to the frame mover. I know this code might be a little confusing with out posting some of the other lua's in the addon but im pretty sure all important parts are there.
Code:
local addonName, addon = ... addon:RegisterDefaultSetting("lockFrames", false) --[[----------------------------------------------------------------------------- Frames to allow moving and saving -------------------------------------------------------------------------------]] --["FrameName"] = false - move the frame --true - move the frame's parent instead --string - move the named frame instead function addon:DefaultMoveableFrames() GMoveableFrames = { ['MiniMapLFGFrame'] = false, ['MiniMapBattlefieldFrame'] = false, ['ShardBarFrame'] = false, ['BNToastFrame'] = false, ['RuneFrame'] = false, ['SpellBookFrame'] = false, ['QuestLogFrame'] = false, ['FriendsFrame'] = false, ['LFGParentFrame'] = false, ['KnowledgeBaseFrame'] = true, ['MerchantFrame'] = false, ['MailFrame'] = false, ['DressUpFrame'] = false, ['TaxiFrame'] = false, ['QuestLogFrame'] = false, ['PaperDollFrame'] = true, ['PVPFrame'] = false, ['WatchFrameHeader'] = true, ['VehicleMenuBar'] = false, ['InspectFrame'] = false, ['PlayerTalentFrame'] = false, ['AchievementFrame'] = false, ['AchievementFrameHeader'] = true, ['AchievementFrameCategoriesContainer'] = 'AchievementFrame', ['GlyphFrame'] = 'PlayerTalentFrame', ['CalendarFrame'] = false, ['GrimUIPlayerFrame'] = false, ['GrimUIPartyFrame1'] = false, ['GrimUIPartyFrame2'] = false, ['GrimUIPartyFrame3'] = false, ['GrimUIPartyFrame4'] = false, ['GrimExpBar'] = false, ['GrimRepBar'] = false, ['GDevBar'] = false, } for id = 1, NUM_CONTAINER_FRAMES do GMoveableFrames['ContainerFrame' .. id] = false end end --[[----------------------------------------------------------------------------- Frame hooking -------------------------------------------------------------------------------]] local hookedFrame, parentFrame, movedFrames, oldPoint, oldX, oldY = { }, { } local function GetRelativePosition(frame) local _, _, uiWidth, uiHeight = UIParent:GetRect() local left, bottom, width, height = frame:GetRect() if bottom + height / 2 >= uiHeight / 2 then if left + width / 2 >= uiWidth / 2 then return 'TOPRIGHT', left + width - uiWidth - 1, bottom + height - uiHeight - 1 else return 'TOPLEFT', left, bottom + height - uiHeight - 1 end elseif left + width / 2 >= uiWidth / 2 then return 'BOTTOMRIGHT', left + width - uiWidth - 1, bottom end return 'BOTTOMLEFT', left, bottom end local function OnShow(self) local frame = parentFrame[self] or self local position = movedFrames[frame:GetName()] if position then addon:UnlockFrame(frame) frame:ClearAllPoints() frame:SetPoint(unpack(position)) addon:LockFrame(frame) end end local function OnMouseDown(self, button) if button ~= 'LeftButton' or addon.settings.lockFrames then return end if IsControlKeyDown() and button == 'LeftButton' then local frame = parentFrame[self] or self oldPoint, oldX, oldY = GetRelativePosition(frame) addon:UnlockFrame(frame) frame:StartMoving() end end local function OnMouseUp(self, button) if button ~= 'LeftButton' or not oldPoint then return end local frame = parentFrame[self] or self frame:StopMovingOrSizing() addon:LockFrame(frame) local point, x, y = GetRelativePosition(frame) if point ~= oldPoint or x ~= oldX or y ~= oldY then movedFrames[frame:GetName()] = { point, 'UIParent', x, y } end oldPoint, oldX, oldY = nil, nil, nil end local HookFrame function HookFrame(name, parent) if hookedFrame[name] then return true end local frame = _G[name] if not frame then return end if parent then if type(parent) == 'string' then parent = _G[parent] else parent = frame:GetParent() end if not parent then return end HookFrame(parent:GetName()) while(parentFrame[parent]) do parent = parentFrame[parent] end parentFrame[frame] = parent elseif not name:match("^" .. addonName) then frame:HookScript('OnShow', OnShow) end frame:EnableMouse(true) frame:EnableKeyboard(true) frame:SetMovable(true) frame:SetClampedToScreen(false) frame:HookScript('OnMouseDown', OnMouseDown) frame:HookScript('OnMouseUp', OnMouseUp) hookedFrame[name] = true if movedFrames[name] and frame:IsShown() then OnShow(frame) end return true end --[[----------------------------------------------------------------------------- Initialize -------------------------------------------------------------------------------]] addon.RegisterEvent("MoveFrames-Initialize", 'PLAYER_LOGIN', function(self, event) addon.UnregisterEvent(self, event) movedFrames = addon.settings.movedFrames if type(movedFrames) ~= 'table' then movedFrames = { } addon.settings.movedFrames = movedFrames end addon:RegisterDefaultSetting("movedFrames", true) -- Prevent it from being removed on PLAYER_LOGOUT local function HookFrames(self, event) if not GMoveableFrames then addon:DefaultMoveableFrames() end for name, parent in pairs(GMoveableFrames) do if HookFrame(name, parent) then GMoveableFrames[name] = nil end end if next(GMoveableFrames) then return end addon.UnregisterEvent(self, event) end addon.RegisterEvent("MoveFrames-Hook", 'ADDON_LOADED', HookFrames) HookFrames("MoveFrames-Hook", 'ADDON_LOADED') end) --[[----------------------------------------------------------------------------- in game add remove functions -------------------------------------------------------------------------------]] function addon:AddMoveableFrame() end function addon:RemMoveableFrame() end |
|
11-01-10, 03:21 PM | #4 |
well, what does SetDefaultSettings (or whatever the function was called on line 3 or so) do? I dont see it in your copied code... does a VARIABLES_LOADED event happen to remove the defalut settings and set up your saved settings? I forget if PLAYER_LOGIN comes before or after, but if its after, PLAYER_LOGIN is a just as good.
__________________
Chat Consolidate is the solution to any out of control trade chat. Ignore lines, throttle chat, consolidate posts!Follow the link to find out how! ▲ ▲ ▲ WoWInterface wont let me triforce >.> |
|
11-01-10, 03:30 PM | #5 |
this is the lua that contains the register settings information part of what makes this tricky is im using Vrul's LOD settings lib and AceGUI.
I also have the same problem with only pulling 8 of the table entrys when i try to make the config panel list out the current frames registered for moveing. Idealy the end product is that in game youll have panel on the config panel that has a add/remove frame button and shows you a list of current entrys. Code:
local addonName, addon = ... local defaults = { class = true } --[[----------------------------------------------------------------------------- RegisterDefaultSetting - Allow modules to set their defaults -------------------------------------------------------------------------------]] function addon:RegisterDefaultSetting(key, value) -- Use caution if using this after ADDON_LOADED defaults[key] = value end --[[----------------------------------------------------------------------------- Load settings, apply version conversions as needed, and link to defaults -------------------------------------------------------------------------------]] addon.RegisterEvent("Settings-Load", 'ADDON_LOADED', function(self, event, name) if name ~= addonName then return end addon.UnregisterEvent(self, event) local name, class = UnitClass('player') name = UnitName('player') local realm = GetRealmName() local settings = _G[addonName .. "Settings"] if type(settings) ~= 'table' then settings = { } _G[addonName .. "Settings"] = settings end if type(settings[realm]) ~= 'table' then settings[realm] = { } end if type(settings[realm][name]) ~= 'table' then settings[realm][name] = { class = class } end settings.version = nil -- Reset value on logout (so can iterate over data without issue) addon.settings = setmetatable(settings[realm][name], { __index = defaults }) return settings end) function addon:ResetWTF() local name, class = UnitClass('player') name = UnitName('player') local realm = GetRealmName() local settings = _G[addonName .. "Settings"] if type(settings) == 'table' then settings = { } _G[addonName .. "Settings"] = settings end if type(settings[realm]) == 'table' then settings[realm] = { } end settings.version = nil -- Reset value on logout return settings end --[[----------------------------------------------------------------------------- Remove unused settings or settings that are the same as defaults -------------------------------------------------------------------------------]] addon.RegisterEvent("Settings-Unload", 'PLAYER_LOGOUT', function() local settings = addon.settings for key, value in pairs(settings) do if value == defaults[key] or defaults[key] == nil then settings[key] = nil end end _G[addonName .. "Settings"].version = GetAddOnMetadata(addonName, 'Version') end) --[[----------------------------------------------------------------------------- LOD Configuration -------------------------------------------------------------------------------]] local LOA = LibStub and LibStub('LibOptionsAssist-1.0', true) if not (LOA and select(2, GetAddOnInfo(addonName .. "_Config"))) then return end -- Make sure config support exists addon.configPanel = LOA:AddEntry(addonName, nil, addonName .. "_Config") _G['SLASH_' .. addonName .. 1] = '/' .. addonName _G['SLASH_' .. addonName .. 2] = '/' .. addonName:lower() _G['SLASH_' .. addonName .. 3] = '/' .. addonName:upper() SlashCmdList[addonName] = addon.configPanel InterfaceOptionsFrame:SetFrameStrata('HIGH') InterfaceOptionsFrame.SetFrameStrata = addon.DoNothing local logo = CreateFrame('Frame', nil, InterfaceOptionsFrame) logo:SetHeight(256) logo:SetWidth(256) logo:SetPoint('BOTTOM', InterfaceOptionsFrame, 'TOP', 0, -68) logo:SetBackdrop({ bgFile = [[Interface\AddOns\GrimUI\Media\GrimUILogo]], edgeFile = nil, edgeSize = 0, tile = false, insets = { left = 0, right = 0, top = 0, bottom = 0 } }) logo:Hide() addon.configPanel:SetScript('OnHide', function() InterfaceOptionsFrame:SetWidth(648) logo:Hide() end) addon.configPanel:SetScript('OnShow', function() InterfaceOptionsFrame:SetWidth(800) logo:Show() end) |
|
11-01-10, 04:24 PM | #6 |
and thinking about it lol that registerdefault is trivial since it has nothing to do with the new variable added. it effects a different variable that is called GrimUISettings shorted by addon.settings
its trivial. all the functions pertaining to the moveable frames list are in that first chunk of code. |
|
11-01-10, 05:10 PM | #7 |
perhaps a good place to start is to
/exit wow (or camp should do) and open up your WTF folder and find your addons saved variables. Make sure your saving what you think you are saving... if everything is in tact in your saved variables file, then your problem is with loading the addon, and not saving
__________________
Chat Consolidate is the solution to any out of control trade chat. Ignore lines, throttle chat, consolidate posts!Follow the link to find out how! ▲ ▲ ▲ WoWInterface wont let me triforce >.> |
|
11-01-10, 05:15 PM | #8 |
thats what im saying... stuff is not saved in the saved variable as it should be. why i have no idea.
That big list of frames where it says GMoveableFrames = { tons of stuff } shows up in the saved var as just 8 of the entrys rather then what? 30 of them |
|
11-01-10, 11:37 PM | #9 |
No mater how i do it it has issues, maybe the way to do it is... create the table as before, then, have it add the stuff from the variables file to the table a different way like the table add entry function. then make the function for adding frames just write to the saved variable and the table? i dunno going to bed this is where i left off...
Code:
local addonName, addon = ... addon:RegisterDefaultSetting("lockFrames", false) --[[----------------------------------------------------------------------------- Frames to allow moving and saving -------------------------------------------------------------------------------]] --["FrameName"] = false - move the frame --true - move the frame's parent instead --string - move the named frame instead function addon:DefaultMoveableFrames() GMoveableFrames = { ['MiniMapLFGFrame'] = false, ['MiniMapBattlefieldFrame'] = false, ['ShardBarFrame'] = false, ['BNToastFrame'] = false, ['RuneFrame'] = false, ['SpellBookFrame'] = false, ['QuestLogFrame'] = false, ['FriendsFrame'] = false, ['LFGParentFrame'] = false, ['KnowledgeBaseFrame'] = true, ['MerchantFrame'] = false, ['MailFrame'] = false, ['DressUpFrame'] = false, ['TaxiFrame'] = false, ['QuestLogFrame'] = false, ['PaperDollFrame'] = true, ['PVPFrame'] = false, ['WatchFrameHeader'] = true, ['VehicleMenuBar'] = false, ['InspectFrame'] = false, ['PlayerTalentFrame'] = false, ['AchievementFrame'] = false, ['AchievementFrameHeader'] = true, ['AchievementFrameCategoriesContainer'] = 'AchievementFrame', ['GlyphFrame'] = 'PlayerTalentFrame', ['CalendarFrame'] = false, ['GrimUIPlayerFrame'] = false, ['GrimUIPartyFrame1'] = false, ['GrimUIPartyFrame2'] = false, ['GrimUIPartyFrame3'] = false, ['GrimUIPartyFrame4'] = false, ['GrimExpBar'] = false, ['GrimRepBar'] = false, ['GDevBar'] = false, } for id = 1, NUM_CONTAINER_FRAMES do GMoveableFrames['ContainerFrame' .. id] = false end end addon:DefaultMoveableFrames() --[[----------------------------------------------------------------------------- Frame hooking -------------------------------------------------------------------------------]] local hookedFrame, parentFrame, movedFrames, oldPoint, oldX, oldY = { }, { } local function GetRelativePosition(frame) local _, _, uiWidth, uiHeight = UIParent:GetRect() local left, bottom, width, height = frame:GetRect() if bottom + height / 2 >= uiHeight / 2 then if left + width / 2 >= uiWidth / 2 then return 'TOPRIGHT', left + width - uiWidth - 1, bottom + height - uiHeight - 1 else return 'TOPLEFT', left, bottom + height - uiHeight - 1 end elseif left + width / 2 >= uiWidth / 2 then return 'BOTTOMRIGHT', left + width - uiWidth - 1, bottom end return 'BOTTOMLEFT', left, bottom end local function OnShow(self) local frame = parentFrame[self] or self local position = movedFrames[frame:GetName()] if position then addon:UnlockFrame(frame) frame:ClearAllPoints() frame:SetPoint(unpack(position)) addon:LockFrame(frame) end end local function OnMouseDown(self, button) if button ~= 'LeftButton' or addon.settings.lockFrames then return end if IsControlKeyDown() and button == 'LeftButton' then local frame = parentFrame[self] or self oldPoint, oldX, oldY = GetRelativePosition(frame) addon:UnlockFrame(frame) frame:StartMoving() end end local function OnMouseUp(self, button) if button ~= 'LeftButton' or not oldPoint then return end local frame = parentFrame[self] or self frame:StopMovingOrSizing() addon:LockFrame(frame) local point, x, y = GetRelativePosition(frame) if point ~= oldPoint or x ~= oldX or y ~= oldY then movedFrames[frame:GetName()] = { point, 'UIParent', x, y } end oldPoint, oldX, oldY = nil, nil, nil end local HookFrame function HookFrame(name, parent) if hookedFrame[name] then return true end local frame = _G[name] if not frame then return end if parent then if type(parent) == 'string' then parent = _G[parent] else parent = frame:GetParent() end if not parent then return end HookFrame(parent:GetName()) while(parentFrame[parent]) do parent = parentFrame[parent] end parentFrame[frame] = parent elseif not name:match("^" .. addonName) then frame:HookScript('OnShow', OnShow) end frame:EnableMouse(true) frame:EnableKeyboard(true) frame:SetMovable(true) frame:SetClampedToScreen(false) frame:HookScript('OnMouseDown', OnMouseDown) frame:HookScript('OnMouseUp', OnMouseUp) hookedFrame[name] = true if movedFrames[name] and frame:IsShown() then OnShow(frame) end return true end --[[----------------------------------------------------------------------------- Initialize -------------------------------------------------------------------------------]] local moveableframes = {} addon.RegisterEvent("MoveFrames-Initialize", 'PLAYER_LOGIN', function(self, event) addon.UnregisterEvent(self, event) movedFrames = addon.settings.movedFrames if type(movedFrames) ~= 'table' then movedFrames = { } addon.settings.movedFrames = movedFrames end addon:RegisterDefaultSetting("movedFrames", true) -- Prevent it from being removed on PLAYER_LOGOUT local function HookFrames(self, event) moveableframes = GMoveableFrames if type(moveableframes) ~= 'table' then moveableframes = { } GMoveableFrames = moveableframes end for name, parent in pairs(moveableframes) do if HookFrame(name, parent) then moveableframes[name] = nil end end if next(moveableframes) then return end addon.UnregisterEvent(self, event) end addon.RegisterEvent("MoveFrames-Hook", 'ADDON_LOADED', HookFrames) HookFrames("MoveFrames-Hook", 'ADDON_LOADED') end) --[[----------------------------------------------------------------------------- in game add remove functions -------------------------------------------------------------------------------]] function addon:AddMoveableFrame() end function addon:RemMoveableFrame() end |
|
11-02-10, 06:30 AM | #10 |
what is your SavedVariables name?
is it GMoveableFrames? cause that looks like it gets replaced anyhow everytime the default thing is called. lets say for instance that your saved variable is called MyAddonDB does anywhere in the file have MyAddonDB = GMoveableFrames? if it does, is it intended to copy all the values over? (because thats not what the above statement is saying) I think before you do a /reload you need to /dump MySavedVariable read whats actually in your table, do a /reload and look in your .lua... it should be an exact copy of what you just dumped. I know its not saving what your expecting, but honestly, i can hardly read whats going on in that code, i dont see anything about any saved variables anywhere. edit:: oh i see this now Code:
movedFrames = addon.settings.movedFrames if type(movedFrames) ~= 'table' then movedFrames = { } addon.settings.movedFrames = movedFrames end addon:RegisterDefaultSetting("movedFrames", true)
__________________
Chat Consolidate is the solution to any out of control trade chat. Ignore lines, throttle chat, consolidate posts!Follow the link to find out how! ▲ ▲ ▲ WoWInterface wont let me triforce >.> Last edited by Xubera : 11-02-10 at 06:32 AM. |
|
11-02-10, 07:48 AM | #11 |
GMoveableFrames and addon.settings.blahblah are BOTH saved variables in the toc file. The addon.settings.blahblah's are defined all through out the addon that is the general settings variable data.
addon.settings.blahblah stands for GrimUISettings in the toc file. your getting lost in the rest of the code... there is only two parts important to what is going on here... forget about the addon.settings variables they work just fine. its the GMoveableFrames and the moveableframes are the two things that are not working proper. moveableframes represents a table, and GMoveableFrames is supposed to represent your saved vars. On load the saved vars from GMoveableFrames should be loaded to table moveableframes. then on logout it should dump the table to the saved variables again to save any frames added or removed. I have tried doing this as just saved variables and ditching the table but i get the same result. no mater how i go about working this the max number of table entrys i can get to dump to the savedvariable is 8. even if i ditch ALL the code and just put GMoveableFrames = {list of entrys more then 8} it still only puts 8 of them in the saved var file. this little chunk Code:
function addon:DefaultMoveableFrames() GMoveableFrames = { ['MiniMapLFGFrame'] = false, ['MiniMapBattlefieldFrame'] = false, ['ShardBarFrame'] = false, ['BNToastFrame'] = false, ['RuneFrame'] = false, ['SpellBookFrame'] = false, ['QuestLogFrame'] = false, ['FriendsFrame'] = false, ['LFGParentFrame'] = false, ['KnowledgeBaseFrame'] = true, ['MerchantFrame'] = false, ['MailFrame'] = false, ['DressUpFrame'] = false, ['TaxiFrame'] = false, ['QuestLogFrame'] = false, ['PaperDollFrame'] = true, ['PVPFrame'] = false, ['WatchFrameHeader'] = true, ['VehicleMenuBar'] = false, ['InspectFrame'] = false, ['PlayerTalentFrame'] = false, ['AchievementFrame'] = false, ['AchievementFrameHeader'] = true, ['AchievementFrameCategoriesContainer'] = 'AchievementFrame', ['GlyphFrame'] = 'PlayerTalentFrame', ['CalendarFrame'] = false, ['GrimUIPlayerFrame'] = false, ['GrimUIPartyFrame1'] = false, ['GrimUIPartyFrame2'] = false, ['GrimUIPartyFrame3'] = false, ['GrimUIPartyFrame4'] = false, ['GrimExpBar'] = false, ['GrimRepBar'] = false, ['GDevBar'] = false, } for id = 1, NUM_CONTAINER_FRAMES do GMoveableFrames['ContainerFrame' .. id] = false end end addon:DefaultMoveableFrames() Code:
--[[----------------------------------------------------------------------------- Initialize -------------------------------------------------------------------------------]] local moveableframes = {} addon.RegisterEvent("MoveFrames-Initialize", 'PLAYER_LOGIN', function(self, event) addon.UnregisterEvent(self, event) movedFrames = addon.settings.movedFrames if type(movedFrames) ~= 'table' then movedFrames = { } addon.settings.movedFrames = movedFrames end addon:RegisterDefaultSetting("movedFrames", true) -- Prevent it from being removed on PLAYER_LOGOUT local function HookFrames(self, event) moveableframes = GMoveableFrames if type(moveableframes) ~= 'table' then moveableframes = { } GMoveableFrames = moveableframes end for name, parent in pairs(moveableframes) do if HookFrame(name, parent) then moveableframes[name] = nil end end if next(moveableframes) then return end addon.UnregisterEvent(self, event) end addon.RegisterEvent("MoveFrames-Hook", 'ADDON_LOADED', HookFrames) HookFrames("MoveFrames-Hook", 'ADDON_LOADED') end) Last edited by Grimsin : 11-02-10 at 08:07 AM. |
|
11-02-10, 07:58 AM | #12 |
and this... this is what it s putting in the wtf.
Code:
GrimUISettings = { ["Icecrown"] = { ["Dropdeadfred"] = { ["showBagBar"] = 1, ["movedFrames"] = { }, ["chatInitialized"] = true, ["macaroonInitialized"] = true, ["money"] = 731660, ["class"] = "MAGE", ["showMicroBar"] = 1, ["resolution"] = "1920x1200", }, ["Holyblood"] = { ["resolution"] = "1920x1200", ["money"] = 50713, ["chatInitialized"] = true, ["macaroonInitialized"] = true, ["movedFrames"] = { }, ["class"] = "PALADIN", ["showMicroBar"] = 1, ["showBagBar"] = 1, }, ["Bakhand"] = { ["xpBarvar"] = "xpLeft", ["chatInitialized"] = true, ["macaroonInitialized"] = true, ["money"] = 954875, ["class"] = "WARRIOR", ["showMicroBar"] = 1, ["resolution"] = "1920x1200", ["movedFrames"] = { }, ["showCombatLog"] = false, ["showBagBar"] = false, }, ["Bulldur"] = { ["showBagBar"] = false, ["movedFrames"] = { }, ["chatInitialized"] = true, ["macaroonInitialized"] = true, ["money"] = 174521, ["class"] = "SHAMAN", ["showMicroBar"] = 1, ["resolution"] = "1920x1200", }, ["Grimsin"] = { ["chatInitialized"] = true, ["macaroonInitialized"] = true, ["money"] = 64010081, ["class"] = "WARLOCK", ["showMicroBar"] = 1, ["resolution"] = "1920x1200", ["showWatchFrame"] = false, ["movedFrames"] = { ["AchievementFrame"] = { "TOPLEFT", -- [1] "UIParent", -- [2] 526.0000746465307, -- [3] -192.0000390101926, -- [4] }, ["PlayerTalentFrame"] = { "TOPLEFT", -- [1] "UIParent", -- [2] 146.0000175721588, -- [3] -194.9999804597594, -- [4] }, }, ["showCombatLog"] = false, ["repBarvar"] = "repLeft", ["showBagBar"] = false, }, ["Deaddoornail"] = { ["chatInitialized"] = true, ["macaroonInitialized"] = true, ["money"] = 22501814, ["class"] = "DEATHKNIGHT", ["showMicroBar"] = 1, ["resolution"] = "1920x1200", ["movedFrames"] = { ["RuneFrame"] = { "BOTTOMLEFT", -- [1] "UIParent", -- [2] 120.0000331762359, -- [3] 421.0002525470669, -- [4] }, }, ["showCombatLog"] = false, ["showWatchFrame"] = false, ["showBagBar"] = false, }, ["Hootinany"] = { ["chatInitialized"] = true, ["macaroonInitialized"] = true, ["money"] = 101928, ["class"] = "ROGUE", ["showMicroBar"] = 1, ["resolution"] = "1920x1200", ["showContextMenu"] = 1, ["movedFrames"] = { }, ["showBagBar"] = 1, }, ["Moojuice"] = { ["resolution"] = "1920x1200", ["money"] = 192885, ["chatInitialized"] = true, ["macaroonInitialized"] = true, ["movedFrames"] = { }, ["class"] = "DRUID", ["showMicroBar"] = 1, ["showBagBar"] = 1, }, ["Chakazulu"] = { ["xpBarvar"] = "xpLeft", ["chatInitialized"] = true, ["macaroonInitialized"] = true, ["money"] = 186213, ["class"] = "PRIEST", ["showMicroBar"] = 1, ["resolution"] = "1920x1200", ["movedFrames"] = { }, ["showCombatLog"] = false, ["showBagBar"] = false, }, ["Bullsbreath"] = { ["xpBarvar"] = "xpLeft", ["chatInitialized"] = true, ["macaroonInitialized"] = true, ["money"] = 2406033, ["class"] = "HUNTER", ["showMicroBar"] = 1, ["resolution"] = "1920x1200", ["movedFrames"] = { }, ["showBagBar"] = false, }, }, ["version"] = "4.0.1.10", } GMoveableFrames = { ["GlyphFrame"] = "PlayerTalentFrame", ["LFGParentFrame"] = false, ["InspectFrame"] = false, } GTipNotesDB = { ["Cooldruid"] = "does this work", } you see how GMoveableFrames has only 3 entrys? when gmoveableframes is set in the lua above it has like 30 entrys. |
|
11-02-10, 08:02 AM | #13 |
I think I see your issue, but currently at work so I can't go into deep detail (coding on a phone sucks). It looks like you have a few spots where you're trying to copy tables but are instead just changing reference points. I'll double check when I get home this afternoon and post if someone doesn't beat me to it.
EDIT: Also, you don't need to exit WoW to check your saved variables. They're saved after you /reload the UI. Much easier and less of a hassle that way. Last edited by Sythalin : 11-02-10 at 08:05 AM. |
|
11-02-10, 08:28 AM | #14 |
I must admit I don't overlook your code. (especially not the addon.RegisterEvent thingi ... where does it come from??)
But I know the addons code is loaded and exectuted before the saved vars are loaded - which means the DefaultMoveableFrames() stuff will be done and then GMoveableFrames will be loaded from the saved vars. Or? What happens if you delete the addons saved vars file? Does the new file then contain all the table entries from GMoveableFrames? |
|
11-02-10, 08:40 AM | #15 | |
The way it should all work is... when you load the game the addon should check the saved vars for the GMoveableFrames entry, if it does not find it then it should load the big list of frames in the lua, if it does then it should load the list in the savedvars wtf instead. Then on log out save any frames added/removed. Which leads me to another question... would it be better for me to have the add remove frame function enter table entrys or should i make that function put the entrys in the saved var file? once i figure out how to get things to go back and forth properly... note - some of the way it should work i know is not right but when i did it the way i first thought i still had the only 8 entrys problem so i tried this way... and a few other ways. here is the registerevent functions... its in the core.lua Code:
--[[----------------------------------------------------------------------------- Event handling - Use one frame to process multiple individual OnEvent needs -------------------------------------------------------------------------------]] do local frame, select, next, events = CreateFrame('Frame'), select, pairs({ }) local register, unregister = frame.RegisterEvent, frame.UnregisterEvent frame:Hide() frame:SetScript('OnEvent', function(self, event, ...) for reference, func in next, events[event], nil do func(reference, event, ...) end end) function addon.RegisterEvent(reference, event, func) if not events[event] then events[event] = { } register(frame, event) end events[event][reference] = func end function addon.RegisterEvents(reference, func, ...) local event for index = 1, select('#', ...) do event = select(index, ...) if not events[event] then events[event] = { } register(frame, event) end events[event][reference] = func end end function addon.UnregisterEvent(reference, event) if events[event] then events[event][reference] = nil if not next(events[event]) then events[event] = nil unregister(frame, event) end end end function addon.UnregisterAllEvents(reference) for event, registry in next, events, nil do registry[reference] = nil if not next(registry) then events[event] = nil unregister(frame, event) end end end end --[[----------------------------------------------------------------------------- SafeCall - Queue a method of addon to run once combat ends if needed -------------------------------------------------------------------------------]] do local combatLockdown, queue = InCombatLockdown(), { } addon.RegisterEvent("Core-SafeCall-EnterCombat", 'PLAYER_REGEN_DISABLED', function(self) combatLockdown = true end) addon.RegisterEvent("Core-SafeCall-LeaveCombat", 'PLAYER_REGEN_ENABLED', function(self) combatLockdown = nil for method, arg in pairs(queue) do addon[method](addon, arg) queue[method] = nil end end) function addon:SafeCall(method, arg) if combatLockdown then queue[method] = arg or false else addon[method](addon, arg) end end end Last edited by Grimsin : 11-02-10 at 08:47 AM. |
||
11-02-10, 08:44 AM | #16 |
and you all think your confused... GrimUI has become a beast...
ok ok... i got a somewhat new idea... what if... instead of coping table to the saved var, I make it so there is the default table, then on AddonLoaded i have a function that checks the saved variables for the GMoveableFrames entry, if it finds it rather then try to copy it over i simply have the function do tinsert to the table for each GMoveableFrames entry. Make the addframe function put entrys into the saved vars and update the table. The only problem with that is that the frames in the main table could never be removed from in game... well they could but the first time you logged out and in it would reenter those frames because they are in the main table... you know whats real annoying to... is that other parts of the code that Vrul helped/did do exactly what we are talking about but i tried to copy his method and it didnt work lol. like that addon.settings.movedframes does exactly what i want the moveableframes to do lol. Last edited by Grimsin : 11-02-10 at 09:04 AM. |
|
11-02-10, 09:38 AM | #17 |
You're on the right track. Ok, bear with me if there are typos, still at work.
lua Code:
This is the simplest way to check your vars. |
|
11-02-10, 10:41 AM | #18 |
you could say
Code:
local defaultTableList = { MiniMapLFGFrame = false, MiniMapBattlefieldFrame = false, ShardBarFrame = false, BNToastFrame = false, RuneFrame = false, SpellBookFrame = false -- etc } --and then in your register frame be like GMoveableFrames = GMoveablesFrame or {} --incase it doesnt exist for k,v in pairs(defaultTableList) do if GMoveableFrames[k] == nil then GMoveablesFrames[k] = v end end "not table[k]" means the value stored into table[k] can EITHER be nil or false. so if a user sets his setting to false, and you use not table[k], then his settings will be overridden each reload
__________________
Chat Consolidate is the solution to any out of control trade chat. Ignore lines, throttle chat, consolidate posts!Follow the link to find out how! ▲ ▲ ▲ WoWInterface wont let me triforce >.> |
|
11-02-10, 10:55 AM | #19 |
Oke ... I would say the point is this part:
Code:
for name, parent in pairs(GMoveableFrames) do if HookFrame(name, parent) then GMoveableFrames[name] = nil end end It sets the table value for every hooked frame to nil. If the frame couldn't be hooked or if the frame doesn't exist (!) it doesn't set the table value to nil. Code:
local frame = _G[name] if not frame then return end The point is, the three frames you find in you saved vars (GlyphFrame, LFGParentFrame, and InspectFrame) don't exist before the player actually uses them. The are created on demand. Other frames (my guess is all other frames ... but tested it only for PVPFrame which indeed exist) are created on load. That means the code snippet above clears the table, except the three non-existent (at least on PLAYER_LOGIN) frames. Last edited by Duugu : 11-02-10 at 11:03 AM. |
|
11-02-10, 10:58 AM | #20 |
Additionally, if you are looking for a direct copy you can use
lua Code:
|
|
WoWInterface » Developer Discussions » Lua/XML Help » saving tables as variables in the saved variables |
«
Previous Thread
|
Next Thread
»
|
Thread Tools | |
Display Modes | |
|
|