Quantcast

Update AddonCore to re-include Printf

James Whitehead II [12-01-10 - 16:37]
Update AddonCore to re-include 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
 -------------------------------------------------------------------------]]--