Whenever I log in, a pet is summoned and then immediately dismissed. This can be cleaned up a bit. I think the same thing happens if you just click the "Make random team" button (since the team doesn't change randomly yet).
Before setting a pet, check if it's a different pet first:
local petGUID = C_PetJournal.GetPetLoadOutInfo(1)
if petID ~= petGUID then
C_PetJournal.SetPetLoadOutInfo(1, petID) -- Pet slot 1
end
However, this doesn't work since petGUID is nil at login for some reason. Maybe there's an event that will signal when the information is available? The simplest alternative is to not do anything if it's nil:
print("|cFF4169E1 Setting team...!")
local petGUID = C_PetJournal.GetPetLoadOutInfo(1)
if not petGUID then
print("|cFFADFF2F Not ready to set team!")
return
end
Then have the 1 second timer do the initial setteam call:
MPB_didsetteam = false
local function MPB_onUpdate(self,elapsed)
...
if MPB_timerOneSec >= 1 then
if not MPB_didsetteam then
local desiredPetLevel = EditBox_PetLevel:GetText() -- Get user input for desired pet level
MyPetBattle.setTeam(desiredPetLevel) -- Setup our team
local petGUID = C_PetJournal.GetPetLoadOutInfo(1)
if petGUID then
MPB_didsetteam = true
end
end
Whenever I log in, a pet is summoned and then immediately dismissed. This can be cleaned up a bit. I think the same thing happens if you just click the "Make random team" button (since the team doesn't change randomly yet).
Before setting a pet, check if it's a different pet first:
However, this doesn't work since petGUID is nil at login for some reason. Maybe there's an event that will signal when the information is available? The simplest alternative is to not do anything if it's nil:
Then have the 1 second timer do the initial setteam call: