diff ConsoleHandlers.lua @ 13:cc98f28b1c7c tip

remove geradd message fix issue with -- add support for console commands
author Jay Bird <a4blank@yahoo.com>
date Thu, 13 Jan 2011 20:50:34 +0300
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ConsoleHandlers.lua	Thu Jan 13 20:50:34 2011 +0300
@@ -0,0 +1,44 @@
+
+function RTT:HandleCommand(cmd)
+  local args = {}
+  for token in string.gmatch(cmd, "[^%s]+") do
+    table.insert(args, token)
+  end
+
+  local command = args[1]
+  local method = "Handle" .. command:sub(1, 1):upper() .. command:sub(2)
+  if RTT[method] == nil then
+    print("Unknown command " .. method)
+    return
+  end
+  RTT[method](self, args)
+end
+
+function RTT:HandleToggle()
+end
+
+function RTT:HandleShow()
+  self:ShowFrame()
+end
+
+function RTT:HandleHide()
+  self:HideFrame()
+end
+
+function RTT:HandleSave(args)
+  local name = args[2]
+  self:Save(name)
+end
+
+function RTT:HandleLoad(args)
+  local name = args[2]
+  self:Load(name)
+end
+
+function RTT:HandleDelete(args)
+  local name = args[2]
+  self.db.profile.setups[name] = nil
+end
+
+
+RTT:RegisterChatCommand("rtt", function(cmd) RTT:HandleCommand(cmd) end)