2 local characterID
= ("%s - %s"):format(GetRealmName(), UnitName("player"));
4 local function Initialize()
5 -- Make sure the required tables exist
6 if(type(RifterDB
) ~= "table") then
9 if(type(RifterDB
.CurrentProfile
) ~= "table") then
10 RifterDB
.CurrentProfile
= {};
12 if(type(RifterDB
.Profiles
) ~= "table") then
13 RifterDB
.Profiles
= {};
15 -- If the current character has no profile assigned to it, assign it a profile equal to his CharacterID (RealmName - CharName)
16 Rifter
:SetProfile(RifterDB
.CurrentProfile
[characterID
] or characterID
);
17 Rifter
.events
:Fire("DatabaseReady");
20 -- Return the current profile, has a valid response only after DatabaseReady has triggered.
21 function Rifter
:GetProfile()
22 return RifterDB
.CurrentProfile
[characterID
];
25 -- Set the current profile to the passed profileName
26 function Rifter
:SetProfile(profileName
)
27 if(type(RifterDB
.Profiles
[profileName
]) ~= "table") then
28 RifterDB
.Profiles
[profileName
] = {};
30 Rifter
.CurrentProfile
= RifterDB
.Profiles
[profileName
];
31 local oldProfile
= RifterDB
.CurrentProfile
[characterID
];
32 RifterDB
.CurrentProfile
[characterID
] = profileName
;
33 if(oldProfile
~= profileName
) then
34 Rifter
.events
:Fire("ProfileChanged", oldProfile
, profileName
);
38 -- Register the InitializeCore callback on which we'll call our initializer function
39 Rifter
.RegisterCallback("Profiles", "InitializeCore", Initialize
);