If you want to change your own layout via slash commands try this.
First you need to add a SavedVariables command to yout TOC file.
Example TOC
Code:
## Interface: 30200
## Author: yyy
## Title: myTestLayout
## Notes: yyy
## SavedVariablesPerCharacter: myTestLayoutVariables
myTestLayout.lua
Now you need to add slash commands and a default setting to your layout.
Example LUA
Code:
--load the savedvariables data
myTestLayoutVariables = myTestLayoutVariables or {}
--the default layout if none is set
local default_layout = 1
------------------------------------------------------
-- / SET UP DEFAULT VALUES / --
------------------------------------------------------
local function load_default()
if(not myTestLayoutVariables.layout) then
myTestLayoutVariables.layout = default_layout
end
end
------------------------------------------------------
-- / FUNCTIONS / --
------------------------------------------------------
--local function dosth()
--DEFAULT_CHAT_FRAME:AddMessage("Hello World!")
--end
local function CreatePlayerStyle1(self, unit)
--do this
end
local function CreatePlayerStyle2(self, unit)
--do that
end
------------------------------------------------------
-- / INIT LAYOUT / --
------------------------------------------------------
local function init_layout()
if myTestLayoutVariables.layout == 2 then
oUF:RegisterStyle("oUF_D3Orbs2_player", CreatePlayerStyle1)
oUF:SetActiveStyle("oUF_D3Orbs2_player")
oUF:Spawn("player", "oUF_D3Orbs2_PlayerFrame"):SetPoint("CENTER",0,0)
else
oUF:RegisterStyle("oUF_D3Orbs2_player", CreatePlayerStyle2)
oUF:SetActiveStyle("oUF_D3Orbs2_player")
oUF:Spawn("player", "oUF_D3Orbs2_PlayerFrame"):SetPoint("CENTER",0,0)
end
end
------------------------------------------------------
-- / SLASH FUNC / --
------------------------------------------------------
local function SlashCmd(cmd)
--getlayout
if (cmd:match"getlayout") then
am("Currently the layout is set to: "..myTestLayoutVariables.layout)
--setlayout
elseif (cmd:match"setlayout") then
local a,b = strfind(cmd, " ");
if b then
local c = strsub(cmd, b+1)
if tonumber(c) then
am("Layout is set to: "..c)
myTestLayoutVariables.layout = tonumber(c)
am("Type in /reload to see the changes.")
--reload_interface()
else
am("No number value.")
end
else
am("No value found.")
end
else
am("commands...")
am("\/mtl setlayout NUMBER (tell me the layout number)")
am("\/mtl getlayout (tells you the set layout number)")
end
end
------------------------------------------------------
-- / LOAD THE **** / --
------------------------------------------------------
local a = CreateFrame"Frame"
a:RegisterEvent("VARIABLES_LOADED")
a:SetScript("OnEvent", function(self)
self:UnregisterEvent("VARIABLES_LOADED")
self:SetScript("OnEvent", nil)
SlashCmdList["mtl"] = SlashCmd;
SLASH_jexp1 = "/mtl";
--load the default
load_default()
--init the layout
init_layout()
end)
The last function calls everything.
It is available after the Variables have been loaded, thus the event.
First the default value gets checked, then the layout will be initialized.
Now you have a new slash command
Hope you get it.
You could do it without the savedvariables but the the layout would use the default setting on every loadup.