vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1  
2 assert( oRA, "oRA not found!")
3  
4 ------------------------------
5 -- Are you local? --
6 ------------------------------
7  
8 local L = AceLibrary("AceLocale-2.2"):new("oRAPItem")
9  
10 -- DO NOT translate these, use the locale tables below
11 local reagents = {
12 ["PRIEST"] = "SacredCandle",
13 ["MAGE"] = "ArcanePowder",
14 ["DRUID"] = "WildThornroot",
15 ["WARLOCK"] = "SoulShard",
16 ["SHAMAN"] = "Ankh",
17 ["PALADIN"] = "SymbolofDivinity",
18 ["ROGUE"] = "FlashPowder",
19 }
20  
21 ----------------------------
22 -- Localization --
23 ----------------------------
24  
25 L:RegisterTranslations("enUS", function() return {
26 ["itemparticipant"] = true,
27 ["item"] = true,
28 ["Item"] = true,
29 ["Options for item checks."] = true,
30 ["SacredCandle"] = "Sacred Candle",
31 ["ArcanePowder"] = "Arcane Powder",
32 ["WildThornroot"] = "Wild Thornroot",
33 ["Ankh"] = "Ankh",
34 ["SoulShard"] = "Soul Shard",
35 ["SymbolofDivinity"] = "Symbol of Divinity",
36 ["FlashPowder"] = "Flash Powder",
37 ["Participant/Item"] = true,
38 ["Disable Checks"] = true,
39 ["Disable"] = true,
40 ["Disable Responding to Item Checks."] = true,
41 } end )
42  
43 L:RegisterTranslations("koKR", function() return {
44  
45 ["Item"] = "아이템",
46 ["Options for item checks."] = "아이템 확인 설정",
47 ["SacredCandle"] = "성스러운 양초",
48 ["ArcanePowder"] = "불가사의한 가루",
49 ["WildThornroot"] = "야생 가시",
50 ["Ankh"] = "십자가",
51 ["SoulShard"] = "영혼의 조각",
52 ["SymbolofDivinity"] = "신앙의 징표",
53 ["FlashPowder"] = "섬광 화약",
54 ["Participant/Item"] = "부분/아이템",
55 ["Disable Checks"] = "확인 응답 안함",
56 ["Disable"] = "사용안함",
57 ["Disable Responding to Item Checks."] = "아이템 확인에 대한 응답을 하지 않습니다.",
58 } end )
59  
60 L:RegisterTranslations("zhCN", function() return {
61 ["itemparticipant"] = "itemparticipant",
62 ["item"] = "物品",
63 ["Options for item checks."] = "物品检查选项",
64 ["SacredCandle"] = "神圣蜡烛",
65 ["ArcanePowder"] = "魔粉",
66 ["WildThornroot"] = "野生棘根草",
67 ["Ankh"] = "十字章",
68 ["SoulShard"] = "灵魂碎片",
69 ["SymbolofDivinity"] = "神圣符印",
70 ["FlashPowder"] = "闪光粉",
71 ["Participant/Item"] = "Participant/Item",
72 ["Disable Checks"] = "禁止检查",
73 ["Disable"] = "禁止",
74 ["Disable Responding to Item Checks."] = "禁止回复物品检查",
75 } end )
76  
77  
78 L:RegisterTranslations("zhTW", function() return {
79 ["itemparticipant"] = "itemparticipant",
80 ["item"] = "物品",
81 ["Options for item checks."] = "物品檢查選項",
82 ["SacredCandle"] = "神聖蠟燭",
83 ["ArcanePowder"] = "魔粉",
84 ["WildThornroot"] = "野生棘根草",
85 ["Ankh"] = "十字章",
86 ["SoulShard"] = "靈魂碎片",
87 ["SymbolofDivinity"] = "神聖符印",
88 ["FlashPowder"] = "閃光粉",
89 ["Participant/Item"] = "隊員/物品",
90 ["Disable Checks"] = "停用檢查",
91 ["Disable"] = "停用",
92 ["Disable Responding to Item Checks."] = "停止回應物品檢查。",
93 } end )
94  
95 L:RegisterTranslations("deDE", function() return {
96 ["SacredCandle"] = "Hochheilige Kerze",
97 ["ArcanePowder"] = "Arkanes Pulver",
98 ["WildThornroot"] = "Wilder Dornwurz",
99 ["Ankh"] = "Ankh",
100 ["SymbolofDivinity"] = "Symbol der Offenbarung",
101 ["FlashPowder"] = "Blitzstrahlpulver",
102 ["SoulShard"] = "Seelensplitter",
103 } end )
104  
105 L:RegisterTranslations("frFR", function() return {
106 --["itemparticipant"] = true,
107 --["item"] = true,
108 ["Item"] = "Objet",
109 ["Options for item checks."] = "Options concernant les v\195\169rifications des objets.",
110 ["SacredCandle"] = "Bougie sacr\195\169e",
111 ["ArcanePowder"] = "Poudre des arcanes",
112 ["WildThornroot"] = "Ronceterre sauvage",
113 ["Ankh"] = "Ankh",
114 ["SoulShard"] = "Fragment d'\195\162me",
115 ["SymbolofDivinity"] = "Symbole de divinit\195\169",
116 ["FlashPowder"] = "Poudre aveuglante",
117 ["Participant/Item"] = "Participant/Objet",
118 ["Disable Checks"] = "D\195\169sactiver les v\195\169rifications",
119 ["Disable"] = "D\195\169sactiver",
120 ["Disable Responding to Item Checks."] = "D\195\169sactive l'envoi d'une r\195\169ponse lors des v\195\169rifications des objets.",
121 } end )
122  
123 ----------------------------------
124 -- Module Declaration --
125 ----------------------------------
126  
127 oRAPItem = oRA:NewModule(L["itemparticipant"])
128 oRAPItem.defaults = {
129 disable = false,
130 }
131 oRAPItem.participant = true
132 oRAPItem.name = L["Participant/Item"]
133 oRAPItem.consoleCmd = L["item"]
134 oRAPItem.consoleOptions = {
135 type = "group",
136 desc = L["Options for item checks."],
137 name = L["Item"],
138 args = {
139 [L["Disable"]] = {
140 type = "toggle",
141 name = L["Disable Checks"],
142 desc = L["Disable Responding to Item Checks."],
143 get = function() return oRAPItem.db.profile.disable end,
144 set = function(v) oRAPItem.db.profile.disable = v end,
145 },
146  
147 }
148 }
149  
150 ------------------------------
151 -- Initialization --
152 ------------------------------
153  
154 function oRAPItem:OnEnable()
155 self:RegisterCheck("ITMC", "oRA_ItemCheck")
156 self:RegisterCheck("REAC", "oRA_ReagentCheck")
157 end
158  
159 function oRAPItem:OnDisable()
160 self:UnregisterAllEvents()
161 self:UnregisterCheck("ITMC")
162 self:UnregisterCheck("REAC")
163 end
164  
165  
166 -------------------------
167 -- Event Handlers --
168 -------------------------
169  
170 function oRAPItem:oRA_ItemCheck( msg, author)
171 if not self:IsValidRequest(author) then return end
172 msg = self:CleanMessage(msg)
173 local _, _, itemname = string.find(msg, "^ITMC (.+)$")
174 if itemname then
175 if self.db.profile.disable then
176 self:SendMessage("ITM -1 "..itemname.." "..author)
177 else
178 local numitems = self:GetItems(itemname)
179 if numitems and numitems > 0 then
180 self:SendMessage("ITM "..numitems.." "..itemname.." "..author)
181 end
182 end
183 end
184  
185 end
186  
187 function oRAPItem:oRA_ReagentCheck(msg, author)
188 if not self:IsValidRequest(author) then return end
189 msg = self:CleanMessage(msg)
190 if self.db.profile.disable then
191 self:SendMessage("REA -1 "..author )
192 else
193 local numitems = self:GetReagents()
194 if numitems and numitems > 0 then
195 self:SendMessage("REA " .. numitems .. " " .. author )
196 end
197 end
198 end
199  
200  
201 -------------------------
202 -- Utility Functions --
203 -------------------------
204  
205 function oRAPItem:GetItems( itemname )
206 local numitems = 0
207 for bag = 4, 0, -1 do
208 local size = GetContainerNumSlots(bag)
209 if size > 0 then
210 for slot=1, size, 1 do
211 local ilink = GetContainerItemLink(bag,slot)
212 if ilink then
213 local _, _, name = string.find(ilink, "%[(.+)%]")
214  
215 if string.find(name, itemname) then
216 local _, itemcount, _, _, _ = GetContainerItemInfo(bag,slot)
217 numitems = numitems + itemcount
218 end
219 end
220 end
221 end
222 end
223 return numitems
224 end
225  
226 function oRAPItem:GetReagents()
227 local numitems = -1
228 if UnitClass("player") then
229 local _,class = UnitClass("player")
230 if reagents[class] then
231 numitems = self:GetItems( L[reagents[class]] )
232 end
233 end
234 return numitems
235 end