Thread Tools Display Modes
11/12/14, 06:09 AM   #1
Flagrick
 
Flagrick's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 24
Pb with zo_strformat or itemlink and icon

Hello,

in lootdrop i have added a debug log to see exactly what we loot with more informations,
but I encounter a problem in that code :
Lua Code:
  1. -------------------------------------------------------------------------------
  2. function LootDrop:dbgDrop(iconFilename, c, quantity, text, tag)
  3.  
  4.     if (not self.db.DbgLog) then return end
  5.  
  6.     if ( not iconFilename or iconFilename == '' )then
  7.         iconFilename = [[/esoui/art/icons/icon_missing.dds]]
  8.     end
  9.  
  10.     if (quantity ~= 0) then
  11.         local color = ZO_ColorDef:New( c )
  12.         local dbgText1='[' .. GetTimeString() .. ']:'
  13.  
  14.         if not self.db.DbgLogTime then
  15.             dbgText1 = ''
  16.         end
  17.        
  18.         local icon = CreateIcon(iconFilename)
  19.  
  20.         local dbgText2=zo_strformat( '<<1[//$dx]>> <<2>>', quantity, text)
  21.         --d(dbgText2) --> label OK
  22.        
  23.         if ((tag=='INV') or (tag=='JUNK') or (tag=='MAIL')) then
  24.             dbgText2=zo_strformat( '<<1[//$dx]>> <<2>> |c736F6E(<<3>>)|r', quantity, text, self.ItemToPrint.nb)
  25.         end
  26.  
  27.         local dbgText3='.'
  28.         if tag~='' then dbgText3=' (' .. tag .. ').' end
  29.  
  30.         local finaldbgtext=zo_strformat( '<<1>> <<2>> <<3>><<4>>', dbgText1, icon, dbgText2, dbgText3)
  31.         d(finaldbgtext)
  32.     end
  33. end

d(dbgText2) gives me that :
but in final with finaldbgtext it prints that :
where could come the 'rh', any idea ?

item with tag INV, MAIL or JUNK are correctly print :

I have made a lot of tests but I have no idea to correct it.
I think I do a mistake with itemlink or zo_strformat but I don't know which one.
if someone could help ...
  Reply With Quote
11/12/14, 06:51 AM   #2
merlight
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 671
Those images are not from the exact code you posted. In the code, dbgText1 has a colon at the end, and dbgText2 comprises of quantity, text, without time.

My guess is that quantity=="rh" in some calls, who knows why.

Lua Code:
  1. local dbgText2=zo_strformat( '<<1[//$dx]>> <<2>>', quantity, text)
I have no idea what zo_strformat would do if quantity wasn't a number, so I'd d(type(quantity) .. ": " .. tostring(quantity)) to see.
  Reply With Quote
11/12/14, 07:06 AM   #3
Flagrick
 
Flagrick's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 24
hello Merlight,

time is given by an other addon (pchat), for this example dbgText1 = ''.
i assume that quantity is a number because the function call is :
Lua Code:
  1. --d(dbglabel)--> label ok
  2. self:dbgDrop(icon, color, 1, dbglabel, tag)

and then in
Lua Code:
  1. local dbgText2=zo_strformat( '<<1[//$dx]>> <<2>>', quantity, text)
text = dbglabel, quantity = 1, and tag ='CRAFT'

here the code of CreateIconfunction:
Lua Code:
  1. -------------------------------------------------------------------------------
  2. function CreateIcon(filename, width, height)
  3.     return zo_iconFormat(filename, width or 16, height or 16)
  4. end
  5. -------------------------------------------------------------------------------

I will add in code
Lua Code:
  1. d(type(quantity) .. ": " .. tostring(quantity))
to see if there is something wrong with quantity.
  Reply With Quote
11/12/14, 07:40 AM   #4
Flagrick
 
Flagrick's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 24
done tests :
Lua Code:
  1. local dbgText2=zo_strformat( '<<1[//$dx]>> <<2>>', quantity, text)
  2.         d(dbgText2) --> label OK
  3.         d(type(dbgText2) .. ": " .. tostring(dbgText2))
  4.         d(type(quantity) .. ": " .. tostring(quantity))  --> Quantity OK, it's a number
  5.         d(type(icon) .. ": " ..  tostring(icon))
there the results :


so, it seems that the tostring(dbgText2) gives the 'rh', but why (the type is string) ?
  Reply With Quote
11/12/14, 08:11 AM   #5
Flagrick
 
Flagrick's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 24
FOUND IT !

Lua Code:
  1. --local pctexts = zo_strformat( '|c736F6E(<<1>>%)|r', pccurrent ) --> error
  2. local pctexts = zo_strformat( '(<<1>>%)', pccurrent ) --> OK

and then i use this code in
Lua Code:
  1. local finaldbgtext=zo_strformat( '|c6BB5FF<<1>>|r  |c736F6E-> <<2>> / <<3>>  <<4>>|r |cFFFFFF[<<t:5>>]|r', self:FormatAmount(RealGain), self:FormatAmount(SkillXp), self:FormatAmount(SkillXpTotal), pctexts, skillName )

So, i think that use coloration two times on the same text gives an error with zo_strformat().
it's now corrected.

thx merlight for help.
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » Pb with zo_strformat or itemlink and icon


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