View Single Post
12-29-14, 02:41 AM   #3
atl77
A Chromatic Dragonspawn
Join Date: Oct 2014
Posts: 179
Originally Posted by samyonair View Post
At the end: In file NxUI.lua line 97 is false it has to be changed from
Lua Code:
  1. f:AddMessage (Nx.TXTBLUE..L["Carbonite"].." |cffffffff".. (format (msg, ...) or "nil"), 1, 1, 1)
to
Lua Code:
  1. f:AddMessage (Nx.TXTBLUE..L["Carbonite"].." |cffffffff".. format(msg, (... or "nil")), 1, 1, 1)
, because otherwise it comes to a failure if no Values are found
This will only work if msg requires one further argument; it only fixes a small part of the problem by brushing over the original error.

To make this more failsafe, you'd have to redesign the whole thing so the placeholder for missing arguments could be replaced by some verbose string. I'll think about it and probably come up with some solution later.

Update: here's the function:
Lua Code:
  1. function Nx.prt (...)
  2.     local args = {...}
  3.     local i = 1
  4.     -- replace missing/erroneous placeholders
  5.     function replace_placeholders(placeholder, item)       
  6.         i = i + 1
  7.         if (args[i] == nil) then
  8.             return '[missing argument]'
  9.         end
  10.         if item ~= 's' and item ~= 'q' then
  11.             if type(args[i]) == 'string' and string.match(args[i], '^[.0-9]+$') then
  12.                 return placeholder
  13.             elseif type(args[i]) ~= 'number' then
  14.                 return '[not a number]'
  15.             end
  16.         end
  17.         return placeholder
  18.     end
  19.     args[1] = string.gsub((args[1] or 'nil'), '(%%[0-9.]*([cdeEfgGioqsuxX]))', replace_placeholders)
  20.    
  21.     local f = Nx.prtChatFrm or DEFAULT_CHAT_FRAME
  22.     f:AddMessage (Nx.TXTBLUE..L["Carbonite"].." |cffffffff".. format (unpack(args)), 1, 1, 1)
  23. end

Pushed it to github.

Last edited by atl77 : 12-29-14 at 04:23 AM.
  Reply With Quote