Hi,
I'm trying to Set my Variables OnLoad Here's my code
In the GuildRecruit_Loaded() I set my default values and save them out.
Each of my option boxes (frames) has an OnLoad to function GuildRecruit_OptionsOnLoad()
But when that function starts I get and I get an "attempt to index global 'GuildRecruit_PostOptions' (a nil value). It seems that It's not reading the saved variables.
Any Suggestions???
function GuildRecruit_OnEvent(self, event, ...)
if (event == "VARIABLES_LOADED") then
GuildRecruit_Loaded();
end
end
--[[ PROPAGATE DEFAULTS AND SAVED DATA ]]
function GuildRecruit_Loaded()
-- SET VARIABLES AND DEFAULTS
if (not GuildRecruit_AdOptions) then --AD OPTIONS DEFAULT CHECK AND LOAD
GuildRecruit_AdOptions = GuildRecruit_Defaults["AdOptions"];
DEFAULT_CHAT_FRAME:AddMessage("GuildRecruit AD Options database not found. Generating...");
end
if (not GuildRecruit_PostOptions) then --POST RULES OPTIONS DEFAULT CHECK AND LOAD
GuildRecruit_PostOptions = setglobal(GuildRecruit_Defaults["PostOptions"]);
DEFAULT_CHAT_FRAME:AddMessage("GuildRecruit POST Options database not found. Generating...");
end
if (not GuildRecruit_LinkOptions) then --LINK OPTIONS DEFAULT CHECK AND LOAD
GuildRecruit_LinkOptions = GuildRecruit_Defaults["LinkOptions"];
DEFAULT_CHAT_FRAME:AddMessage("GuildRecruit LINK Options database not found. Generating...");
end
end
--[[ END PROPAGATE DEFAULTS AND SAVED DATA ]]
--[[ BEGIN READING THROUGH SAVED VARIABLES ]]
function GuildRecruit_OptionsOnLoad()
-- LOAD DATA TO OPTIONS BEGIN
local LoadedOptionBox = this:GetName();
if (LoadedOptionBox == "GuildRecruitROption") then --ON POST OPTIONS LOAD PROPAGATE VARAIBLES
for i=1,12 do
local Rtextinput = getglobal("GuildRecruitROption_Text"..i);
local Rtexttemp = "PTxt"..i.."";
local Rtextinputvalue = GuildRecruit_PostOptions[Rtexttemp];
Rtextinput:SetText(Rtextinputvalue);
local Renableinput = getglobal("GuildRecruitROption_Enable"..i);
local Renabletemp = "P"..i.."";
local Renableinputvalue = GuildRecruit_PostOptions[Renabletemp];
Renableinput:SetChecked(Renableinputvalue);
end
out("Loaded Options: "..LoadedOptionBox);
elseif (LoadedOptionBox == "GuildRecruitLOption") then --ON LINKS OPTIONS LOAD PROPAGATE VARAIBLES
for i=1,10 do
local Ltextinput = getglobal("GuildRecruitLOption_Text"..i);
local Ltexttemp = "LTxt"..i.."";
local Ltextinputvalue = GuildRecruit_LinkOptions[Ltexttemp];
out("L feedback: "..Ltexttemp);
Ltextinput:SetText(Ltextinputvalue);
local Lenableinput = getglobal("GuildRecruitLOption_Enable"..i);
local Lenabletemp = "L"..i.."";
local Lenableinputvalue = GuildRecruit_LinkOptions[Lenabletemp];
Lenableinput:SetChecked(Lenableinputvalue);
end
out("Loaded Options: "..LoadedOptionBox);
elseif (LoadedOptionBox == "GuildRecruitAdOptions") then --ON AD OPTIONS LOAD PROPAGATE VARAIBLES
GuildRecruitAdOptions_AdPanel_AdMultiplier:SetText(GuildRecruit_AdOptions["AdMultiplierVal"])
GuildRecruitAdOptions_AdPanel_AdChatNumber:SetText(GuildRecruit_AdOptions["ChanNumVal"]);
GuildRecruitAdOptions_AdMessageEdit:SetText(GuildRecruit_AdOptions["AdMessageVal"]);
out("Loaded Options: "..LoadedOptionBox);
end
-- LOAD DATA TO OPTIONS END
end
|
Please help thanks.
PJ