public
Description: WoW Addon - Automatically restock items from vendors and your bank
Homepage: http://www.tekkub.net
Clone URL: git://github.com/tekkub/stealyourcarbon.git
Click here to lend your support to: stealyourcarbon and make a donation at www.pledgie.com !
stealyourcarbon / SlashHandler.lua
100644 68 lines (50 sloc) 2.556 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
local StealYourCarbon = StealYourCarbon
 
 
------------------------------
-- Slash Commands --
------------------------------
 
SLASH_CARBON1 = "/carbon"
SLASH_CARBON2 = "/syc"
SlashCmdList.CARBON = function(input)
  local cmd, rest = string.match(input, "^%s*(%S+)%s*(.*)$")
  local handler = cmd and StealYourCarbon["CMD_"..cmd:upper()]
 
  if handler then handler(StealYourCarbon, rest)
  else
    StealYourCarbon:Print("Automatically restock items from vendors and your bank")
    ChatFrame1:AddMessage(" /carbon /syc")
    ChatFrame1:AddMessage(" |cffff9933add|r: Add an item to be restocked")
    ChatFrame1:AddMessage(" |cffff9933del|r: Remove an item from the restock list")
    ChatFrame1:AddMessage(" |cffff9933list|r: List current restock items")
    ChatFrame1:AddMessage(" |cffff9933overstock|r: Ensure that the quantity specified is always purchased for items offered in stacks from vendor")
    ChatFrame1:AddMessage(" |cffff9933upgradewater|r: Automatically upgrade to better water as player levels")
    ChatFrame1:AddMessage(" |cffff9933chatter|r: Give chat feedback when purchasing items")
  end
end
 
 
function StealYourCarbon:CMD_ADD(input)
  local id, qty = string.match(input, "item:(%d+):.*%s+(%d+)%s*$")
  if not id or not qty then return self:Print("Usage: /carbon add [Item Link] quantity") end
  self.db.stocklist[tonumber(id)] = tonumber(qty)
  self:PrintF("Added %s x%d", select(2, GetItemInfo(id)), qty)
end
 
 
function StealYourCarbon:CMD_DEL(input)
  local id = string.match(input, "item:(%d+):")
  if not id then return self:Print("Usage: /carbon del [Item Link]") end
  self.db.stocklist[tonumber(id)] = nil
  self:Print("Removed", (select(2, GetItemInfo(id))))
end
 
 
function StealYourCarbon:CMD_LIST()
  if not next(self.db.stocklist) then return self:Print("No items in restock list") end
  self:Print("Restock list")
  for id,qty in pairs(self.db.stocklist) do ChatFrame1:AddMessage(string.format(" %s x%d", select(2, GetItemInfo(id)), qty)) end
end
 
 
function StealYourCarbon:CMD_OVERSTOCK()
  self.db.overstock = not self.db.overstock
  self:Print("Overstocking", (self.db.overstock and "|cff00ff00enabled" or "|cffff0000disabled"))
end
 
 
function StealYourCarbon:CMD_CHATTER()
  self.db.chatter = not self.db.chatter
  self:Print("Purchasing feedback", (self.db.chatter and "|cff00ff00enabled" or "|cffff0000disabled"))
end
 
 
function StealYourCarbon:CMD_UPGRADEWATER()
  self.db.upgradewater = not self.db.upgradewater
  self:Print("Auto-upgrading water", (self.db.upgradewater and "|cff00ff00enabled" or "|cffff0000disabled"))
end