vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | --[[ |
2 | Changelog: |
||
3 | |||
4 | Version 1.2.0 |
||
5 | fixed compeltely disapaering messages by a big moddification in the hook |
||
6 | updated toc |
||
7 | updated silvanaslib |
||
8 | |||
9 | Version 1.1.8 |
||
10 | fixed a small scanning bug that would some unEquipable items show up as useable |
||
11 | |||
12 | Version 1.1.7 |
||
13 | fixed 2 overflown bugs but in a bad way so the might be new probs atleast i tryed to fix it :p |
||
14 | |||
15 | Version 1.1.5 |
||
16 | Fixed a small version number witch i forgot to update |
||
17 | |||
18 | Version 1.1.4 |
||
19 | now only works on chat messages or loot message |
||
20 | |||
21 | Version 1.1.1 |
||
22 | small bug fix for iems whitout a level got shown whit a () level witch is now gone again |
||
23 | |||
24 | Version 1.1.0 |
||
25 | basic sepport added for customiseable colors for some items witch can be set in the "CustomRecolor.lua" |
||
26 | Money coloring now default to off becase of the many unforseen problems... :( |
||
27 | added a new comand to get he number of an item |
||
28 | actioneer sepport fixed for actionneer version 3.6.1 |
||
29 | Setting now get saved and loaded back instead of jsut saved |
||
30 | |||
31 | Version 1.0.8 |
||
32 | Fixed money coloring inside color strings |
||
33 | Hopefully fixed the german stack overflow |
||
34 | Fixed money enable or disable cmds |
||
35 | |||
36 | Version 1.0.5 |
||
37 | Fixed money coloring system trigering on g2g |
||
38 | Fixed error when a nil message was send |
||
39 | Fixed compatibiltie whit Nerfed Combatlog (but not the actual prob that was casing the bug) |
||
40 | |||
41 | Version 1.0.3 |
||
42 | Fixed bug where some item strings where nolonger localised |
||
43 | Fixed a bug where multiple item links in 1 chat message all would link to the first item |
||
44 | Money / itemlink coloing can now be turned on / off seperately |
||
45 | |||
46 | Version 1.0.0 |
||
47 | First working version, after lots of debugging :p |
||
48 | |||
49 | Known Bugs: |
||
50 | |||
51 | Todo: |
||
52 | Code Cleanup (it was nice but after the latest fixed its pure crap again.. |
||
53 | --]] |
||
54 | |||
55 | --main global var |
||
56 | ItemLinkRecolor = { |
||
57 | AddonName = "ItemLinkRecolor", |
||
58 | ["NAME"] = "|cFF33CC66Item Link Recolor|r", |
||
59 | ["VERSION"] = "(|cFF9900001|cFFFFFFFF.|cFF9900002|cFFFFFFFF.|cFF9900000|cFFFFFFFF)|r", |
||
60 | ["AUTHOR"] = "|cff993366Silvanas|r", |
||
61 | ["ENABLED"] = true, |
||
62 | ["ILENABLED"] = true, |
||
63 | ["MLENABLED"] = false, |
||
64 | } |
||
65 | -- |
||
66 | |||
67 | --event that we will color |
||
68 | local ItemLinkRecolor_AllowedEvents = { |
||
69 | ["CHAT_MSG_CHANNEL"] = true, |
||
70 | ["CHAT_MSG_LOOT"] = true, |
||
71 | ["CHAT_MSG_OFFICER"] = true, |
||
72 | ["CHAT_MSG_PARTY"] = true, |
||
73 | ["CHAT_MSG_RAID"] = true, |
||
74 | ["CHAT_MSG_RAID_LEADER"]= true, |
||
75 | ["CHAT_MSG_SAY"] = true, |
||
76 | ["CHAT_MSG_WHISPER"] = true, |
||
77 | ["CHAT_MSG_YELL"] = true, |
||
78 | ["CHAT_MSG_GUILD"] = true, |
||
79 | } |
||
80 | -- |
||
81 | |||
82 | --local hook pointer |
||
83 | local ILR_ItemLinkRecolor_OnEvent_Hook --hooks chatframe events (needed to know the "this:") |
||
84 | -- |
||
85 | |||
86 | --events array |
||
87 | local ItemLinkRecolorEventArray = {} |
||
88 | function ItemLinkRecolor_Event() ItemLinkRecolorEventArray[event]() end |
||
89 | -- |
||
90 | |||
91 | ------------------- |
||
92 | --event triggered-- |
||
93 | ------------------- |
||
94 | --onload |
||
95 | function ItemLinkRecolor_Load() |
||
96 | --load up the custom coloring var |
||
97 | --[[if not ItemLinkRecolor_Custom then |
||
98 | --Silvanas.Print("|cFFFF0000Warning:|r No Costum database detected") |
||
99 | ItemLinkRecolor_Custom = {} --it has tobe a table to prevent errors further down |
||
100 | else |
||
101 | Silvanas.Print("Costum table loaded") |
||
102 | |||
103 | end |
||
104 | --]] |
||
105 | |||
106 | --register events |
||
107 | ItemLinkRecolorEventArray = { |
||
108 | ["VARIABLES_LOADED"] = ItemLinkRecolor_Event_Variables_Loaded, |
||
109 | ["ADDON_LOADED"] = ItemLinkRecolor_Event_Addon_Loaded |
||
110 | } |
||
111 | this:RegisterEvent("VARIABLES_LOADED") |
||
112 | this:RegisterEvent("ADDON_LOADED") |
||
113 | |||
114 | --set up commands |
||
115 | Silvanas.AddCmd("ITEMLINKRECOLOR_CMD",ItemLinkRecolor_Cmd_ItemLinkRecolor,{"ilr","ItemLinkRecolor"}) |
||
116 | end |
||
117 | |||
118 | ---on event |
||
119 | --this is after ll saved variabled ar laoded back in mem |
||
120 | function ItemLinkRecolor_Event_Variables_Loaded() |
||
121 | --function to reset saved variables |
||
122 | local ItemLinkRecolorReset = function() |
||
123 | ItemLinkRecolorSavedVars = { |
||
124 | ["VERSION"] = ItemLinkRecolor["VERSION"], |
||
125 | ["ENABLED"] = ItemLinkRecolor["ENABLED"], |
||
126 | ["ILENABLED"] = ItemLinkRecolor["ILENABLED"], |
||
127 | ["MLENABLED"] = ItemLinkRecolor["MLENABLED"], |
||
128 | } |
||
129 | end |
||
130 | |||
131 | --basic chatframe event hook |
||
132 | ILR_ItemLinkRecolor_OnEvent_Hook = ChatFrame_OnEvent |
||
133 | ChatFrame_OnEvent = ItemLinkRecolor_ChatFrame_OnEvent |
||
134 | |||
135 | --load up saved variables |
||
136 | if not ItemLinkRecolorSavedVars then |
||
137 | --if there are no saved vars thne well relaod the default |
||
138 | ItemLinkRecolorReset() |
||
139 | else |
||
140 | if ItemLinkRecolorSavedVars["VERSION"] and ItemLinkRecolorSavedVars["VERSION"] == ItemLinkRecolor["VERSION"] then |
||
141 | --if there are saved vars and they are saved under the good version then load em up |
||
142 | ItemLinkRecolor["ENABLED"] = ItemLinkRecolorSavedVars["ENABLED"] |
||
143 | ItemLinkRecolor["ILENABLED"] = ItemLinkRecolorSavedVars["ILENABLED"] |
||
144 | ItemLinkRecolor["MLENABLED"] = ItemLinkRecolorSavedVars["MLENABLED"] |
||
145 | else |
||
146 | --if there are saved vars but under the wrong version then reload the default |
||
147 | ItemLinkRecolorReset() |
||
148 | end |
||
149 | end |
||
150 | |||
151 | --loaded message |
||
152 | Silvanas.Print(ItemLinkRecolor["NAME"] .." |cFFFFFFFFversion: ".. ItemLinkRecolor["VERSION"] .." |cFFFFFFFFloaded.|r") |
||
153 | end |
||
154 | |||
155 | --this is whenever an addon gets loaded, oO so quite a lot :( |
||
156 | function ItemLinkRecolor_Event_Addon_Loaded() |
||
157 | --auctoineer doesnt like our moddified item names :( so we build deffierent string jsut for auctioneer |
||
158 | if arg1 == "EnhTooltip" then |
||
159 | ItemLinkRecolor_Auctioneer = true |
||
160 | end |
||
161 | end |
||
162 | ------------------- |
||
163 | ------------------- |
||
164 | ------------------- |
||
165 | |||
166 | ----------------------- |
||
167 | --chat hook functions-- |
||
168 | ----------------------- |
||
169 | --this function takes over the real "ChatFrame_OnEvent" and calls the real one afterwards |
||
170 | function ItemLinkRecolor_ChatFrame_OnEvent(event) |
||
171 | --if we got this addon enabled |
||
172 | if ItemLinkRecolor["ENABLED"] then |
||
173 | --if we allow this event |
||
174 | if ItemLinkRecolor_AllowedEvents[event] then |
||
175 | --if we got money coloring enabled |
||
176 | if ItemLinkRecolor["MLENABLED"] then |
||
177 | --Parse money strings and return them in color |
||
178 | arg1 = string.gsub(arg1,"([|]-[c]-%x-[%.,gG]-%d+%s-[gGsScC]%a*)",ItemLinkRecolor_Moneyrize) |
||
179 | end |
||
180 | --if we got itemlink coloring enabled |
||
181 | if ItemLinkRecolor["ILENABLED"] then |
||
182 | --find an item links and return new colored ones |
||
183 | arg1 = string.gsub(arg1,"(|Hitem:%d+:%d+:%d+:%d+|h.-|h)",ItemLinkRecolor_Colorize) |
||
184 | end |
||
185 | end |
||
186 | end |
||
187 | --Call the orriginal function |
||
188 | ILR_ItemLinkRecolor_OnEvent_Hook(event) |
||
189 | end |
||
190 | ----------------------- |
||
191 | ----------------------- |
||
192 | ----------------------- |
||
193 | |||
194 | ---------------------- |
||
195 | --coloring functions-- |
||
196 | ---------------------- |
||
197 | function ItemLinkRecolor_Colorize(texty) |
||
198 | --dont call print functions here else u overflow the stack use a text hook instead |
||
199 | --text = string.format("|cFFFF0000H|cFFFFFFFF:|r %s",text) |
||
200 | |||
201 | --parse elements of the link |
||
202 | local _,_,link,itemnum = string.find(texty,"^|H(item:(%d+):%d+:%d+:%d+)|h") |
||
203 | |||
204 | --Silvanas.Print(itemnum ..", ".. Silvanas.VarPrint(ItemLinkRecolor_Custom[itemnum])) |
||
205 | |||
206 | --get the item atributes |
||
207 | local itemnamereal,_,itemquality,itemlevel = GetItemInfo(link) |
||
208 | local itemname = itemnamereal |
||
209 | |||
210 | --if something went wrong ignore this chat link and return wutever text we recieved |
||
211 | if type(itemquality) == "nil" then --cant just check if its tru since it can also be 0 |
||
212 | return texty |
||
213 | end |
||
214 | |||
215 | --get the quality color |
||
216 | local itemqualitycolor = Silvanas.Select(4,GetItemQualityColor(itemquality)) |
||
217 | |||
218 | --custom stuff |
||
219 | --[[if ItemLinkRecolor_Custom[itemnum] or ItemLinkRecolor_Custom[itemnamereal] then |
||
220 | Silvanas.print("Customizing") |
||
221 | itemname = ItemLinkRecolor_Custom[itemnum].custom_itemname or ItemLinkRecolor_Custom[itemnamereal].custom_itemname or itemname |
||
222 | itemqualitycolor = ItemLinkRecolor_Custom[itemnum].custom_itemcolor or ItemLinkRecolor_Custom[itemnamereal].custom_itemcolor or itemqualitycolor |
||
223 | end |
||
224 | --]] |
||
225 | |||
226 | --build the level display |
||
227 | local playerlevel = UnitLevel("player") |
||
228 | local itemlevelcolor = nil |
||
229 | |||
230 | --custom levelname |
||
231 | --[[if (ItemLinkRecolor_Custom[itemnum] and ItemLinkRecolor_Custom[itemnum].custom_levelname) or (ItemLinkRecolor_Custom[itemnamereal] and ItemLinkRecolor_Custom[itemnamereal].custom_levelname) then |
||
232 | itemlevel = ItemLinkRecolor_Custom[itemnum].custom_levelname or ItemLinkRecolor_Custom[itemnamereal].custom_levelname |
||
233 | end |
||
234 | --]] |
||
235 | |||
236 | if itemlevel == 0 then |
||
237 | --items that dont have a min level |
||
238 | itemlevel = "" |
||
239 | itemlevelcolor = "" |
||
240 | else |
||
241 | --if it isnt a costum string |
||
242 | if type(itemlevel) == "number" then |
||
243 | if itemlevel > (playerlevel + 5) then |
||
244 | itemlevelcolor = "FF0000" |
||
245 | elseif itemlevel > playerlevel then |
||
246 | itemlevelcolor = "FF9933" |
||
247 | elseif itemlevel == playerlevel then |
||
248 | itemlevelcolor = "FFFF00" |
||
249 | elseif itemlevel > (playerlevel - 5) then |
||
250 | itemlevelcolor = "00FF00" |
||
251 | else |
||
252 | itemlevelcolor = "999999" |
||
253 | end |
||
254 | else |
||
255 | --default color for text type levlenames |
||
256 | itemlevelcolor = "FFFFFF" |
||
257 | end |
||
258 | |||
259 | --custom level color |
||
260 | --[[if (ItemLinkRecolor_Custom[itemnum] and ItemLinkRecolor_Custom[itemnum].custom_levelcolor) or (ItemLinkRecolor_Custom[itemnamereal] and ItemLinkRecolor_Custom[itemnamereal].custom_levelcolor) then |
||
261 | itemlevelcolor = ItemLinkRecolor_Custom[itemnum].custom_levelcolor or ItemLinkRecolor_Custom[itemnamereal].custom_levelcolor |
||
262 | end |
||
263 | --]] |
||
264 | |||
265 | --finish the itemlevelcolor |
||
266 | itemlevelcolor = "|cFF".. itemlevelcolor |
||
267 | end |
||
268 | |||
269 | --check if we can use it or not |
||
270 | local bracketcolor = nil |
||
271 | |||
272 | --custom bracket colors |
||
273 | --[[if ItemLinkRecolor_Custom[itemnum] or ItemLinkRecolor_Custom[itemnamereal] then |
||
274 | if type(ItemLinkRecolor_Custom[itemnum].custom_Equipable) == "nil" and type(ItemLinkRecolor_Custom[itemnamereal].custom_Equipable) == "nil" then |
||
275 | elseif ItemLinkRecolor_Custom[itemnum].custom_Equipable or ItemLinkRecolor_Custom[itemnamereal].custom_Equipable then |
||
276 | bracketcolor = itemqualitycolor |
||
277 | else |
||
278 | bracketcolor = "|cFFFF0000" |
||
279 | end |
||
280 | end |
||
281 | --]] |
||
282 | |||
283 | --if it isnt already se by the customiseable part |
||
284 | if not bracketcolor then |
||
285 | if type(itemlevel) == "number" and itemlevel > playerlevel then |
||
286 | --if the level is already to high then make the brackets red |
||
287 | bracketcolor = "|cFFFF0000" |
||
288 | else |
||
289 | --see if its Equipable |
||
290 | if ItemLinkRecolor_CanEquip(link) then |
||
291 | bracketcolor = itemqualitycolor |
||
292 | else |
||
293 | bracketcolor = "|cFFFF0000" |
||
294 | end |
||
295 | end |
||
296 | end |
||
297 | |||
298 | --build and return the return value |
||
299 | if ItemLinkRecolor_Auctioneer then |
||
300 | --auctoineer doesnt like our moddified item names :( so we build deffierent string jsut for auctioneer |
||
301 | --so we leave the actual link as it is |
||
302 | if type(itemlevel) == "string" and itemlevel == "" then |
||
303 | --dont dispaly he level for item whitout a minuim level |
||
304 | return "|r".. bracketcolor .."(|r".. itemqualitycolor .. texty .."|r".. bracketcolor ..")|r" |
||
305 | else |
||
306 | return "|r".. bracketcolor .."(|r".. itemlevelcolor .. itemlevel .."|r".. itemqualitycolor .. texty .."|r".. bracketcolor ..")|r" |
||
307 | end |
||
308 | else |
||
309 | --else orriginal nicer way |
||
310 | if type(itemlevel) == "string" and itemlevel == "" then |
||
311 | --dont dispaly he level for item whitout a minuim level |
||
312 | return "|r|H".. link .."|h".. bracketcolor .."[|r".. itemqualitycolor .. itemname .."|r".. bracketcolor .."]|r|h" |
||
313 | else |
||
314 | return "|r|H".. link .."|h".. bracketcolor .."[|r".. itemlevelcolor .."(".. itemlevel ..")|r" .. itemqualitycolor .. itemname .."|r".. bracketcolor .."]|r|h" |
||
315 | end |
||
316 | end |
||
317 | end |
||
318 | |||
319 | --the coloring fuction of money |
||
320 | function ItemLinkRecolor_Moneyrize(texty) |
||
321 | --dont call print functions here else u overflow the stack use a text hook instead |
||
322 | --text = string.format("|cFFFF0000H|cFFFFFFFF:|r %s",text) |
||
323 | |||
324 | --if it isnt a g2g message |
||
325 | if string.find(texty,"[gG]2[gG]") then |
||
326 | return texty |
||
327 | end |
||
328 | |||
329 | --if its contains a color code |
||
330 | local colorcode,returntext |
||
331 | colorcode = Silvanas.Select(3,string.find(texty,"^|c(%x+)")) |
||
332 | |||
333 | --if we are trying to color inside the colorcode then ignore this money and return wutever txt we had |
||
334 | if colorcode then |
||
335 | if string.len(colorcode) < 8 then |
||
336 | return texty |
||
337 | else |
||
338 | --cut off the color code but still and it in the end |
||
339 | colorcode = string.sub(texty,1,10) |
||
340 | returntext = string.sub(texty,11) |
||
341 | end |
||
342 | else |
||
343 | returntext = texty |
||
344 | colorcode = "" |
||
345 | end |
||
346 | |||
347 | --parse money |
||
348 | local _,_,money1,money2,moneytype,moneystr = string.find(texty,"^(%d-)[%.,]-(%d+)%s-([gGsScC])(%a*)$") |
||
349 | |||
350 | --if something went wrong ignore this chat link and return wutever text we recieved |
||
351 | if moneytype then |
||
352 | moneytype = string.upper(moneytype) |
||
353 | else |
||
354 | --if something went wrong ignore this chat link and return wutever text we recieved |
||
355 | return texty |
||
356 | end |
||
357 | |||
358 | --see if moneystr is part of an other word |
||
359 | if moneystr ~= "" then |
||
360 | moneystr = string.lower(moneystr) |
||
361 | --see if our moneytype and moneystr are valid |
||
362 | if moneytype == "G" then |
||
363 | if moneystr ~= "old" then |
||
364 | return texty |
||
365 | end |
||
366 | elseif moneytype == "S" then |
||
367 | if moneystr ~= "ilver" then |
||
368 | return texty |
||
369 | end |
||
370 | else |
||
371 | if moneystr ~= "opper" then |
||
372 | return texty |
||
373 | end |
||
374 | end |
||
375 | end |
||
376 | |||
377 | --if there is no comma or dot but only 1 number |
||
378 | if money1 == "" then |
||
379 | --if something went wrong ignore this chat link and return wutever text we recieved |
||
380 | if money2 == "" then |
||
381 | return texty |
||
382 | end |
||
383 | |||
384 | --if there is only 1 number then store it in money1 and make money2 0 |
||
385 | money1 = money2 |
||
386 | money2 = 0 |
||
387 | end |
||
388 | |||
389 | --if something went wrong ignore this chat link and return wutever text we recieved |
||
390 | if (money2 ~= 0) and (moneytype == "C") then |
||
391 | --cant hace a comma when the moneytype is "C"'opper' |
||
392 | return texty |
||
393 | end |
||
394 | |||
395 | --calc the money in copper |
||
396 | local mcalc = { ["G"] = 10000, |
||
397 | ["S"] = 100, |
||
398 | ["C"] = 1, } |
||
399 | |||
400 | local moneycopper = (tonumber(money1)*mcalc[moneytype]) + (tonumber(money2)*(mcalc[moneytype] / 100)) |
||
401 | |||
402 | --[[--TEMP FIX FOR NUFED COMBAT LOG |
||
403 | --if money is 0 then ignore it |
||
404 | if moneycopper == 0 then |
||
405 | return texty |
||
406 | end--]] |
||
407 | |||
408 | --get the player his money |
||
409 | local playermoney = GetMoney() |
||
410 | |||
411 | --do the money compare |
||
412 | local quartplayermoney = playermoney / 4 |
||
413 | |||
414 | if moneycopper > (playermoney*2) then |
||
415 | local moneycoler = "FF0000" |
||
416 | elseif moneycopper > playermoney then |
||
417 | local moneycoler = "FF9933" |
||
418 | elseif (moneycopper <= playermoney) and (moneycopper > (quartplayermoney*3)) then |
||
419 | local moneycoler = "FFFF00" |
||
420 | elseif (moneycopper <= (quartplayermoney*3)) and (moneycopper > quartplayermoney) then |
||
421 | local moneycoler = "00FF00" |
||
422 | else |
||
423 | local moneycoler = "999999" |
||
424 | end |
||
425 | |||
426 | --return the new text |
||
427 | return "|cFF".. moneycoler .. returntext .."|r".. colorcode |
||
428 | end |
||
429 | ---------------------- |
||
430 | ---------------------- |
||
431 | ---------------------- |
||
432 | |||
433 | --------------------- |
||
434 | --Checkup Functions-- |
||
435 | --------------------- |
||
436 | function ItemLinkRecolor_CanEquip(link) |
||
437 | --dont call print functions here else u overflow the stack use a text hook instead |
||
438 | --text = string.format("|cFFFF0000H|cFFFFFFFF:|r %s",text) |
||
439 | |||
440 | --tooltip scan function |
||
441 | local ItemLinkRecolor_ToolTipTextIsRed = function(TooltipFrame) |
||
442 | if TooltipFrame and TooltipFrame:IsVisible() then --dont scan colors of invisable frames |
||
443 | --gets its colors |
||
444 | local ttca,ttcr,ttcg,ttcb |
||
445 | ttcr,ttcg,ttcb,ttca = TooltipFrame:GetTextColor() |
||
446 | |||
447 | --if its red then we assume we cant use this item (yes its not a clean and save way but it saves cpu usage) |
||
448 | --if (ttcr == 0.99999780301005) and (ttcg == 0.12548992037773) and (ttcb == 0.12548992037773) and (ttca == 0.99999779462814) then |
||
449 | if ttcr > 0.99999 and (ttcg > 0.125 and ttcg < 0.126) and (ttcb > 0.125 and ttcb < 0.126) and (ttca > 0.99999) then |
||
450 | return true |
||
451 | end |
||
452 | end |
||
453 | return false |
||
454 | end |
||
455 | |||
456 | --first clear the tooltip |
||
457 | ItemLinkRecolorScanningTooltip:ClearLines() |
||
458 | |||
459 | --set the link |
||
460 | ItemLinkRecolorScanningTooltip:SetHyperlink(link) |
||
461 | |||
462 | --oke we search in a hidden tooltip to find if there are any red lines so we cant use it :p |
||
463 | local TooltipText |
||
464 | local i |
||
465 | |||
466 | for i=1,ItemLinkRecolorScanningTooltip:NumLines(),1 do --go over each line |
||
467 | --get one left text object |
||
468 | TooltipTextFrame = getglobal("ItemLinkRecolorScanningTooltipTextLeft".. i) |
||
469 | |||
470 | --if the text is red we return false since we assume we cant Equip it |
||
471 | if ItemLinkRecolor_ToolTipTextIsRed(TooltipTextFrame) then |
||
472 | return false |
||
473 | end |
||
474 | |||
475 | if (i == 2) or (i == 3) then --2,3 RIGHT is the armor type |
||
476 | --get the right text object |
||
477 | TooltipTextFrame = getglobal("ItemLinkRecolorScanningTooltipTextRight".. i) |
||
478 | |||
479 | --if the text is red we return false since we assume we cant Equip it |
||
480 | if ItemLinkRecolor_ToolTipTextIsRed(TooltipTextFrame) then |
||
481 | return false |
||
482 | end |
||
483 | end |
||
484 | end |
||
485 | |||
486 | --if nothing in red was found we assume we can use use it |
||
487 | return true |
||
488 | end |
||
489 | |||
490 | ------------ |
||
491 | --commands-- |
||
492 | ------------ |
||
493 | function ItemLinkRecolor_Cmd_ItemLinkRecolor(msg) |
||
494 | --if there is any parameter given to the command |
||
495 | if msg ~= "" then |
||
496 | --to lower case so its nolonger case sensetive |
||
497 | msg = string.lower(msg) |
||
498 | |||
499 | --stringsub it so we only extract the part we need espacilay hand if u have multiple parameters |
||
500 | if string.sub(msg,1,6) == "enable" then |
||
501 | --set the vars |
||
502 | ItemLinkRecolor["ENABLED"] = true |
||
503 | ItemLinkRecolorSavedVars["ENABLED"] = true |
||
504 | |||
505 | --update mod intoo the silvanasaddonlib |
||
506 | Silvanas.AddMod(ItemLinkRecolor) |
||
507 | |||
508 | --print the messsage |
||
509 | Silvanas.Print(ItemLinkRecolor["NAME"] .." Enabled") |
||
510 | return |
||
511 | |||
512 | elseif string.sub(msg,1,7) == "disable" then |
||
513 | --set the vars |
||
514 | ItemLinkRecolor["ENABLED"] = false |
||
515 | ItemLinkRecolorSavedVars["ENABLED"] = false |
||
516 | |||
517 | --update mod intoo the silvanasaddonlib |
||
518 | Silvanas.AddMod(ItemLinkRecolor) |
||
519 | |||
520 | --print the messsage |
||
521 | Silvanas.Print(ItemLinkRecolor["NAME"] .." Disabled") |
||
522 | return |
||
523 | |||
524 | elseif string.sub(msg,1,8) == "itemlink" then |
||
525 | if string.sub(msg,10,15) == "enable" then |
||
526 | --set the vars |
||
527 | ItemLinkRecolor["ILENABLED"] = true |
||
528 | ItemLinkRecolorSavedVars["ILENABLED"] = true |
||
529 | |||
530 | --update mod intoo the silvanasaddonlib |
||
531 | Silvanas.AddMod(ItemLinkRecolor) |
||
532 | |||
533 | --print the messsage |
||
534 | Silvanas.Print(ItemLinkRecolor["NAME"] .." ItemLink Colering Enabled") |
||
535 | return |
||
536 | |||
537 | elseif string.sub(msg,10,16) == "disable" then |
||
538 | --set the vars |
||
539 | ItemLinkRecolor["ILENABLED"] = false |
||
540 | ItemLinkRecolorSavedVars["ILENABLED"] = false |
||
541 | |||
542 | --update mod intoo the silvanasaddonlib |
||
543 | Silvanas.AddMod(ItemLinkRecolor) |
||
544 | |||
545 | --print the messsage |
||
546 | Silvanas.Print(ItemLinkRecolor["NAME"] .." ItemLink Colering Disabled") |
||
547 | return |
||
548 | |||
549 | end |
||
550 | elseif string.sub(msg,1,5) == "money" then |
||
551 | if string.sub(msg,7,13) == "enable" then |
||
552 | --set the vars |
||
553 | ItemLinkRecolor["MLENABLED"] = true |
||
554 | ItemLinkRecolorSavedVars["MLENABLED"] = true |
||
555 | |||
556 | --update mod intoo the silvanasaddonlib |
||
557 | Silvanas.AddMod(ItemLinkRecolor) |
||
558 | |||
559 | --print the messsage |
||
560 | Silvanas.Print(ItemLinkRecolor["NAME"] .." Money Colering Enabled") |
||
561 | return |
||
562 | |||
563 | elseif string.sub(msg,7,14) == "disable" then |
||
564 | --set the vars |
||
565 | ItemLinkRecolor["MLENABLED"] = false |
||
566 | ItemLinkRecolorSavedVars["MLENABLED"] = false |
||
567 | |||
568 | --update mod intoo the silvanasaddonlib |
||
569 | Silvanas.AddMod(ItemLinkRecolor) |
||
570 | |||
571 | --print the messsage |
||
572 | Silvanas.Print(ItemLinkRecolor["NAME"] .." Money Colering Disabled") |
||
573 | return |
||
574 | |||
575 | end |
||
576 | elseif string.sub(msg,1,6) == "getnum" then |
||
577 | Silvanas.Print(string.gsub(msg,"|","!")) |
||
578 | |||
579 | --get the number and name |
||
580 | local x,inum,iname |
||
581 | x,x,inum,iname = string.find(msg,"|hitem:(%d+):%d+:%d+:%d+|h(.-)|h",8) |
||
582 | |||
583 | Silvanas.Print(Silvanas.VarPrint(inum) ..", ".. Silvanas.VarPrint(iname)) |
||
584 | |||
585 | --if we could find it |
||
586 | if inum and iname then |
||
587 | Silvanas.Print(ItemLinkRecolor["NAME"] ..": The ItemNumber of ".. iname .." is: ".. inum) |
||
588 | else |
||
589 | Silvanas.Print(ItemLinkRecolor["NAME"] ..": Invalid itemlink") |
||
590 | end |
||
591 | return |
||
592 | |||
593 | end |
||
594 | end |
||
595 | --basic help display for unknown commands |
||
596 | Silvanas.Print(ItemLinkRecolor["NAME"] .." |cFFFFFFFFversion: ".. ItemLinkRecolor["VERSION"] .." |cFF999999ItemLinkRecolor Options:") |
||
597 | Silvanas.Print("|cFF999999/ItemLinkRecolor (/ilr) |cFFFFFF99[option]|cFFFFFFFF: |cFF999999Sets |cFFFFFF99[option]") |
||
598 | Silvanas.Print("|cFFFFFF99Enabled |cFFFFFFFF:Turns ".. ItemLinkRecolor["NAME"] .." |cFF9999FF[on]") |
||
599 | Silvanas.Print("|cFFFFFF99Disabled |cFFFFFFFF:Turns ".. ItemLinkRecolor["NAME"] .." |cFF9999FF[off]") |
||
600 | Silvanas.Print("|cFFFFFF99ItemLink Enabled|cFFFFFFFF:Turns ItemLink Coloring |cFF9999FF[on]") |
||
601 | Silvanas.Print("|cFFFFFF99ItemLink Disabled|cFFFFFFFF:Turns ItemLink Coloring |cFF9999FF[off]") |
||
602 | Silvanas.Print("|cFFFFFF99Money Enabled|cFFFFFFFF:Turns ItemLink Coloring |cFF9999FF[on]") |
||
603 | Silvanas.Print("|cFFFFFF99Money Disabled|cFFFFFFFF:Turns Money Coloring |cFF9999FF[off]") |
||
604 | Silvanas.Print("|cFFFFFF99GetNum <ItemLink>|cFFFFFFFF:Gets the ItemNumber out of the ItemLink") |
||
605 | end |
||
606 | ------------ |
||
607 | ------------ |
||
608 | ------------ |