Quantcast

Re-add Printf

James Whitehead II [11-24-10 - 21:42]
Re-add Printf
Filename
AddonCore.lua
diff --git a/AddonCore.lua b/AddonCore.lua
index d524340..a765133 100644
--- a/AddonCore.lua
+++ b/AddonCore.lua
@@ -52,6 +52,22 @@ if EMERGENCY_DEBUG then
 end

 --[[-------------------------------------------------------------------------
+--  Print/Printf support
+-------------------------------------------------------------------------]]--
+
+local printHeader = "|cFF33FF99%s|r: "
+
+function addon:Printf(msg, ...)
+    msg = printHeader .. msg
+    local success, txt = pcall(string.format, msg, addonName, ...)
+    if success then
+        print(txt)
+    else
+        error(string.gsub(txt, "'%?'", string.format("'%s'", "Printf")), 3)
+    end
+end
+
+--[[-------------------------------------------------------------------------
 --  Event registration and dispatch
 -------------------------------------------------------------------------]]--