View Single Post
06-24-19, 04:50 PM   #5
LudiusMaximus
A Rage Talon Dragon Guard
 
LudiusMaximus's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 320
I had a quick look at the Addon.

First of all, I did in fact get an error because it tries to register the events LOOT_STARTED and LOOT_STOPPED which do not exist (any more?). See MountMiniMe.lua, line 95.
It should probably be LOOT_OPENED and LOOT_CLOSED?
https://wowwiki.fandom.com/wiki/Events/L

I commented this out:
Code:
-- self:RegisterEvent("LOOT_STARTED", Addon.LootStartedHandler);
-- self:RegisterEvent("LOOT_STOPPED", Addon.LootStoppedHandler);
Then I did not get an error any more.

I tried to locate the code that is executed when you mount up and found it in event.lua, line 21:

Code:
function Addon:HandleMountStart()
	Addon:debug_print('HandleMountStart');
	
	AddonTable.StealthPetId = nil;
	
	local hunterModeOp = self:GetHunterModeOperation();
	-- self:debug_print('hunterModeOp' .. tostring(hunterModeOp));
	
	if Addon:IsHunterMode() and IsPetActive() and (hunterModeOp == 'keep') then
		-- Addon:debug_print('Hunter op is keep, not summoning mount pet');
		return;
	end
	
	local shapeshiftModeOp = self:GetShapeshiftModeOperation();
	self:debug_print('shapeshiftModeOp = ' .. tostring(shapeshiftModeOp));
  
	if Addon:IsShapeshiftMode() and AddonTable.PlayerShapeshifted and (shapeshiftModeOp == 'keep') then
		Addon:debug_print('Shapeshift op is keep, not summoning mount pet');
		return;
	end
	
	
	local mountSpellId = Addon:FindMountSpellId()
	AddonTable.SummonDelay = AddonTable.DefaultSummonDelay;
	Addon:SummonPet(Addon:FindPetIdForMountSpellId(mountSpellId));	
end
As you can see it has lots of debug_print() calls which would actually be helpful. To activate them, you have to set the AddonTable.DEBUG variable to true in MountMiniMe.lua, line 9:

Code:
AddonTable.DEBUG = true;

In the last line of HandleMountStart() you see the call of SummonPet() taking as its argument the return value of Addon:FindPetIdForMountSpellId(mountSpellId).

Beforehand, the variable mountSpellID gets assigned the return value of FindMountSpellId().
I checked to see what it returns by adding a print() command to the code:

Code:
local mountSpellId = Addon:FindMountSpellId()

-- My new command to see the value of mountSpellId.
-- (You actually do not need ; at the end of lines in lua.)  
print("mountSpellId", mountSpellId)
  
AddonTable.SummonDelay = AddonTable.DefaultSummonDelay;
Addon:SummonPet(Addon:FindPetIdForMountSpellId(mountSpellId));
This showed me that the return value of FindMountSpellId() is "nil", which is apparently why everything else from here on cannot work either.

To see what is wrong I located FindMountSpellId() in util.lua, line 39.

Code:
function Addon:FindMountSpellId()
	-- No use trying to find a mount if we're not mounted
	if not IsMounted() then
		return nil
	end

	local buffs, i = {}, 1;
	local name, _, _, _, _, _, _, _, _, _, spellId = UnitBuff("player", i);
	while name do
		if AddonTable.MountCollection[spellId] then
			return spellId
		end
		i = i + 1;
		name, _, _, _, _, _, _, _, _, _, spellId = UnitBuff("player", i);
	end
end
This function obviously tries to find out what mount you are on by iterating through all active buffs.

I added the line
Code:
print (name, spellId)
to see what was going on and found that, spellId was always nil already. I searched the web for UnitBuff() and found that spellId is actually the 10th, not the 11th return value. This was probably something that got changed in the API at some point (?). I changed the code to:

Code:
function Addon:FindMountSpellId()
	-- No use trying to find a mount if we're not mounted
	if not IsMounted() then
		return nil
	end

	local buffs, i = {}, 1;
	-- local name, _, _, _, _, _, _, _, _, _, spellId = UnitBuff("player", i);
	local name, _, _, _, _, _, _, _, _, spellId = UnitBuff("player", i);
  
	print ("These are the active buffs:")
	while name do
		print (name, spellId)
  
		if AddonTable.MountCollection[spellId] then
			return spellId
		end
		i = i + 1;
		-- name, _, _, _, _, _, _, _, _, _, spellId = UnitBuff("player", i);
		name, _, _, _, _, _, _, _, _, spellId = UnitBuff("player", i);
	end
end

This seems to have done the trick I guess...?

I could have told you just the solution right away, but maybe by explaining how I found it you could see that it is not too difficult.
"Give a man a fish and you feed him for a day; teach a man to fish and you feed him for a lifetime." :-)
  Reply With Quote