Thread Tools Display Modes
12-01-19, 11:45 AM   #1
tinyu
A Molten Giant
 
tinyu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 837
Trying to revice _Corpse

Trying to revive an addon called _Corpse

I am making the necessary C_FriendList changes and I am getting this error

Code:
Date: 2019-12-02 04:09:02
ID: 1
Error occured in: Global
Count: 1
Message: ..\AddOns\_Corpse\_Corpse.Standard.lua line 305:
   function arguments expected near '.'
Debug:
   [C]: ?
this line in question looks like this

Code:
self:C_FriendList.AddFriend( Name );
before the change it was this

Code:
self:AddFriend( Name );
This is the entire section of code it is in

Code:
--[[****************************************************************************
  * Function: _Corpse.Standard:Update                                          *
  ****************************************************************************]]
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
			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
			self:C_FriendList.AddFriend( Name );
		end
	end
end
Thank you for any and all help.
__________________
"There's no such thing as too many addons."
Lothaer
Titan Dev Team Member.
  Reply With Quote
12-01-19, 03:28 PM   #2
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,237
Change the line to the following. There is no "self" attached to the Blizzard API.
Code:
C_FriendList.AddFriend( Name )
  Reply With Quote
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
12-05-19, 01:01 PM   #4
Urtgard
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Apr 2016
Posts: 25
The error message says: string expected, got table. Name should be a string but somehow it's a table.
Why is that? C_FriendList.GetFriendInfo(Name) returns a table with a bunch of info: https://wow.gamepedia.com/API_C_Frie....GetFriendInfo
If you just want the name you can use C_FriendList.GetFriendInfo(Name).name
  Reply With Quote

WoWInterface » Classic - AddOns, Compliations, Macros » Classic - AddOn Help/Support » Trying to revice _Corpse

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off