changeset 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 d2cbfe498c4d
children
files ConsoleHandlers.lua Main.lua RaidTargetTactics.toc
diffstat 3 files changed, 52 insertions(+), 4 deletions(-) [+]
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)
--- a/Main.lua	Sat Dec 04 05:53:52 2010 +0300
+++ b/Main.lua	Thu Jan 13 20:50:34 2011 +0300
@@ -304,12 +304,15 @@
     local channel = self:GetDefaultChatChannel()
     if channel then
         for _, data in ipairs(self:GetFormData()) do
-            local str = table.concat(data, " — ")
+            local str = data.icon
+            if data.action then
+              str = str .. " — " .. data.action
+            end
+            if data.player then
+              str = str .. " — " .. data.player
+            end
             SendChatMessage(str, channel)
         end
-        if UnitName("player") == "Герадд" then
-            SendChatMessage("Герадд любит тебя!", channel)
-        end
     end
 end
 
--- a/RaidTargetTactics.toc	Sat Dec 04 05:53:52 2010 +0300
+++ b/RaidTargetTactics.toc	Thu Jan 13 20:50:34 2011 +0300
@@ -16,3 +16,4 @@
 PartyInfo.lua
 NameDialog.lua
 Main.lua
+ConsoleHandlers.lua