View Single Post
12-01-19, 10:34 PM   #3
tinyu
A Molten Giant
 
tinyu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 837
Originally Posted by myrroddin View Post
Change the line to the following. There is no "self" attached to the Blizzard API.
Code:
C_FriendList.AddFriend( Name )
Thank you, I solved another couple errors but now I am stuck with this one.

Code:
Date: 2019-12-02 14:56:13
ID: 1
Error occured in: Global
Count: 7
Message: ..\AddOns\_Corpse\_Corpse.lua line 51:
   bad argument #1 to 'format' (string expected, got table)
Debug:
   [C]: ?
   [C]: format()
   _Corpse\_Corpse.lua:51: BuildCorpseTooltip()
   _Corpse\_Corpse.Standard.lua:299: Update()
   _Corpse\_Corpse.lua:147:
      _Corpse\_Corpse.lua:142
   [C]: ?
   [C]: ?
Here is line 51 from Corpse.Lua

local Text = L.CORPSE_FORMAT:format( Name );
which is apart of this

Code:
function me.BuildCorpseTooltip ( Hostile, Name, Level, Class, Location, ConnectedStatus, Status )
	if ( Hostile == nil ) then
		return;
	end
	if ( ConnectedStatus == nil ) then -- Returned from GetFriendInfo
		ConnectedStatus = 0; -- Offline represented differently
	end

	-- Build first line
	local Text = L.CORPSE_FORMAT:format( Name );
	local Color = FACTION_BAR_COLORS[ Hostile and 2 or 6 ];
	GameTooltipTextLeft1:SetTextColor( Color.r, Color.g, Color.b );
	local Right = GameTooltipTextRight1;
	if ( Status and #Status > 0 ) then -- AFK or DND
		Color = NORMAL_FONT_COLOR;
		Right:SetText( Status );
		Right:SetTextColor( Color.r, Color.g, Color.b );
		Right:Show()
	else
		Right:Hide();
	end

	-- Add second status line
	if ( ConnectedStatus ) then -- Connected status is known
		if ( ConnectedStatus == 0 ) then
			Text = L.OFFLINE;
			Color = GRAY_FONT_COLOR;
		else -- Online
			if ( Class ) then -- Show details
				if ( Level ) then
					Text = L.LEVEL_CLASS_PATTERN:format( Level, Class );
				else
					Text = Class;
				end
			else -- Plain online
				Text = L.ONLINE;
			end
			Color = HIGHLIGHT_FONT_COLOR;
		end
		if ( GameTooltip:NumLines() < 2 ) then
			GameTooltip:AddLine( Text, Color.r, Color.g, Color.g );
		else -- Line already shown
			local Left = GameTooltipTextLeft2;
			Left:SetText( Text );
			Left:SetTextColor( Color.r, Color.g, Color.g );
			Left:Show();
			GameTooltipTextRight2:Hide();
		end
	end

	-- Hack to effectively resize the tooltip without breaking FadeOut() like Show() does
	GameTooltip:AppendText( "" );
end
this is line 299 of Corpse.Standard.lua

Code:
_Corpse.BuildCorpseTooltip( false, C_FriendList.GetFriendInfo( Name ) );
which is part of
Code:
function me:Update ( Name )
	local PlayerName = UnitName( "player" );

	if ( Name == PlayerName ) then -- Our own corpse
		_Corpse.BuildCorpseTooltip( false, PlayerName,
			UnitLevel( "player" ), UnitClass( "player" ), GetRealZoneText(), 1,
			( UnitIsAFK( "player" ) and CHAT_FLAG_AFK ) or ( UnitIsDND( "player" ) and CHAT_FLAG_DND ) );
	elseif ( self.Enemies[ Name ] ~= nil ) then
		_Corpse.BuildCorpseTooltip( true, Name, nil, nil, nil, self.Enemies[ Name ] );
		self:InviteUnit( Name );
	else
		if ( C_FriendList.GetFriendInfo( Name ) ) then -- Player already a friend
			C_FriendList.ShowFriends();
			-- Build tooltip with possibly old data
			_Corpse.BuildCorpseTooltip( false, C_FriendList.GetFriendInfo( Name ) );
		else
			if ( self.Allies[ Name ] ~= nil ) then
				_Corpse.BuildCorpseTooltip( false, Name , nil, nil, nil,
					self.Allies[ Name ] == 0 and 0 or false ); -- Don't fill in if last seen online
			end
			C_FriendList.AddFriend( Name );
		end
	end
end
and this is line 142 and 147 of Corpse.lua
Code:
function me:GameTooltipOnShow ()

me.ActiveModule:Update( Name, Server ); -- Add data to tooltip using module's info
part of

Code:
function me:GameTooltipOnShow ()
	-- Tooltip contents updated
	if ( me.ActiveModule ) then
		local Name, Server = me.GetCorpseName();
		if ( Name ) then -- Found corpse tooltip
			me.ActiveModule:Update( Name, Server ); -- Add data to tooltip using module's info
		end
	end
end

thank you for your help.
__________________
"There's no such thing as too many addons."
Lothaer
Titan Dev Team Member.
  Reply With Quote