vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | SM_INV_SLOT = { |
2 | ["AMMOSLOT"]=0, |
||
3 | ["HEADSLOT"]=1, |
||
4 | ["NECKSLOT"]=2, |
||
5 | ["SHOULDERSLOT"]=3, |
||
6 | ["SHIRTSLOT"]=4, |
||
7 | ["CHESTSLOT"]=5, |
||
8 | ["WAISTSLOT"]=6, |
||
9 | ["LEGSSLOT"]=7, |
||
10 | ["FEETSLOT"]=8, |
||
11 | ["WRISTSLOT"]=9, |
||
12 | ["HANDSSLOT"]=10, |
||
13 | ["FINGER0SLOT"]=11, |
||
14 | ["FINGER1SLOT"]=12, |
||
15 | ["TRINKET0SLOT"]=13, |
||
16 | ["TRINKET1SLOT"]=14, |
||
17 | ["BACKSLOT"]=15, |
||
18 | ["MAINHANDSLOT"]=16, |
||
19 | ["SECONDARYHANDSLOT"]=17, |
||
20 | ["RANGEDSLOT"]=18, |
||
21 | ["TABARDSLOT"]=19, |
||
22 | ["BAG0SLOT"]=20, |
||
23 | ["BAG1SLOT"]=21, |
||
24 | ["BAG2SLOT"]=22, |
||
25 | ["BAG3SLOT"]=23, |
||
26 | } |
||
27 | |||
28 | SlashCmdList["SUPERMACRO"] = function(msg) |
||
29 | local info = ChatTypeInfo["SYSTEM"]; |
||
30 | local text; |
||
31 | local cmd = gsub(msg,"^%s*(%a*)%s*(.*)%s*$","%1" ); |
||
32 | local param = gsub(msg,"^%s*(%a*)%s*([%w %p]*)%s*$","%2" ); |
||
33 | if ( cmd=="hideaction") then |
||
34 | text = param; |
||
35 | if ( text == "0" or text=="false") then |
||
36 | SM_VARS.hideAction = 0; |
||
37 | HideActionText(); |
||
38 | elseif ( text == "1" or text=="true") then |
||
39 | SM_VARS.hideAction = 1; |
||
40 | HideActionText(); |
||
41 | else |
||
42 | ChatFrame_DisplaySlashHelp("SUPERMACRO",3,3); |
||
43 | end |
||
44 | if ( not SM_VARS.hideAction ) then SM_VARS.hideAction = 0; end |
||
45 | text = "SM_VARS.hideAction is "..SM_VARS.hideAction; |
||
46 | if ( SuperMacroOptionsFrame:IsVisible() ) then |
||
47 | SuperMacroOptionsFrame_OnShow(); |
||
48 | end |
||
49 | DEFAULT_CHAT_FRAME:AddMessage( text, info.r, info.g, info.b, info.id); |
||
50 | return; |
||
51 | end |
||
52 | if ( cmd=="printcolor" ) then |
||
53 | text = param; |
||
54 | if ( text =="default" ) then |
||
55 | SM_VARS.printColor.r = PRINT_COLOR_DEF.r; |
||
56 | SM_VARS.printColor.g = PRINT_COLOR_DEF.g; |
||
57 | SM_VARS.printColor.b = PRINT_COLOR_DEF.b; |
||
58 | if ( SuperMacroOptionsFrame:IsVisible() ) then |
||
59 | SuperMacroOptionsFrame_OnShow(); |
||
60 | end |
||
61 | return; |
||
62 | end |
||
63 | if ( gsub(text,"%s*","")=="" ) then |
||
64 | ChatFrame_DisplaySlashHelp("SUPERMACRO",4,4); |
||
65 | return; |
||
66 | end |
||
67 | local color = gsub(msg, ".*color%s*(.*)","%1"); |
||
68 | local red = gsub(color, "%s*(-?%d*%.*%d*)%s*.*","%1"); |
||
69 | local green = gsub(color, "%s*(-?%d*%.*%d*)%s*(-?%d*%.*%d*)%s*(-?%d*%.*%d*)%s*.*","%2"); |
||
70 | local blue = gsub(color, "%s*(-?%d*%.*%d*)%s*(-?%d*%.*%d*)%s*(-?%d*%.*%d*)%s*.*","%3"); |
||
71 | red = tonumber(red) or 0; |
||
72 | green = tonumber(green) or 0; |
||
73 | blue = tonumber(blue) or 0; |
||
74 | red = (red < 0 and 0) or (red > 1 and 1) or red; |
||
75 | green = (green < 0 and 0) or (green > 1 and 1) or green; |
||
76 | blue = (blue < 0 and 0) or (blue > 1 and 1) or blue; |
||
77 | SM_VARS.printColor = { r=red,g=green,b=blue }; |
||
78 | if ( SuperMacroOptionsFrame:IsVisible() ) then |
||
79 | SuperMacroOptionsFrame_OnShow(); |
||
80 | end |
||
81 | return; |
||
82 | end |
||
83 | if ( cmd=="macrotip" ) then |
||
84 | text = param; |
||
85 | if ( text =="default" ) then |
||
86 | SM_VARS.macroTip1 = 1; |
||
87 | SM_VARS.macroTip2 = 0; |
||
88 | if ( SuperMacroOptionsFrame:IsVisible() ) then |
||
89 | SuperMacroOptionsFrame_OnShow(); |
||
90 | end |
||
91 | return; |
||
92 | end |
||
93 | text = tonumber(text); |
||
94 | if ( text and text >= 0 and text <= 3) then |
||
95 | if ( mod(text, 2) == 1 ) then |
||
96 | SM_VARS.macroTip1 = 1; |
||
97 | else |
||
98 | SM_VARS.macroTip1 = 0; |
||
99 | end |
||
100 | if ( text >= 2 ) then |
||
101 | SM_VARS.macroTip2 = 1; |
||
102 | else |
||
103 | SM_VARS.macroTip2 = 0; |
||
104 | end |
||
105 | if ( SuperMacroOptionsFrame:IsVisible() ) then |
||
106 | SuperMacroOptionsFrame_OnShow(); |
||
107 | end |
||
108 | else |
||
109 | ChatFrame_DisplaySlashHelp("SUPERMACRO",5,6); |
||
110 | end |
||
111 | return; |
||
112 | end |
||
113 | if ( cmd=="options" ) then |
||
114 | ShowUIPanel(SuperMacroOptionsFrame); |
||
115 | return; |
||
116 | end |
||
117 | |||
118 | ChatFrame_DisplaySlashHelp("SUPERMACRO"); |
||
119 | return; |
||
120 | end |
||
121 | |||
122 | SlashCmdList["MACRO"] = function(msg) |
||
123 | if(not msg or msg == "") then |
||
124 | ShowUIPanel(SuperMacroFrame); |
||
125 | else |
||
126 | RunMacro(msg); |
||
127 | end |
||
128 | end |
||
129 | |||
130 | -- use item |
||
131 | SlashCmdList["SMUSE"] = function(msg) |
||
132 | use(unpack(ListToTable(msg))); |
||
133 | end |
||
134 | |||
135 | -- equip item |
||
136 | SlashCmdList["SMEQUIP"] = function(msg) |
||
137 | use(unpack(ListToTable(msg))); |
||
138 | end |
||
139 | |||
140 | -- equip offhand item |
||
141 | SlashCmdList["SMEQUIPOFF"] = function(msg) |
||
142 | local bag, slot = FindItem(TrimSpaces(msg)); |
||
143 | if ( bag and slot ) then |
||
144 | PickupContainerItem(bag, slot); |
||
145 | PickupInventoryItem(17); |
||
146 | end |
||
147 | end |
||
148 | |||
149 | -- unequip item by part or name |
||
150 | SlashCmdList["SMUNEQUIP"] = function(msg) |
||
151 | local e,f = FindLastEmptyBagSlot(); |
||
152 | if ( e ) then |
||
153 | PickupInventoryItem(FindItem(TrimSpaces(msg))); |
||
154 | PickupContainerItem(e,f); |
||
155 | end |
||
156 | end |
||
157 | |||
158 | -- print text to chatframe |
||
159 | SlashCmdList["SMPRINT"] = function(msg) |
||
160 | SM_print(msg); |
||
161 | end |
||
162 | |||
163 | -- after action passed text |
||
164 | SlashCmdList["SMPASS"] = function(msg) |
||
165 | Pass(msg); |
||
166 | end |
||
167 | |||
168 | -- after action failed text |
||
169 | SlashCmdList["SMFAIL"] = function(msg) |
||
170 | Fail(msg); |
||
171 | end |
||
172 | |||
173 | -- use items in order |
||
174 | SlashCmdList["SMDOORDER"] = function(msg) |
||
175 | DoOrder(unpack(ListToTable(msg))); |
||
176 | end |
||
177 | |||
178 | -- channel without interruption |
||
179 | SlashCmdList["SMCHANNEL"] = function(msg) |
||
180 | SM_Channel(msg); |
||
181 | end |
||
182 | |||
183 | function SM_print(msg) |
||
184 | DEFAULT_CHAT_FRAME:AddMessage(msg, SM_VARS.printColor.r, SM_VARS.printColor.g, SM_VARS.printColor.b); |
||
185 | end |
||
186 | |||
187 | if ( not ChatFrame_DisplaySlashHelp ) then |
||
188 | function ChatFrame_DisplaySlashHelp(pre, start, last, frame) |
||
189 | if ( not frame ) then |
||
190 | frame=DEFAULT_CHAT_FRAME; |
||
191 | end |
||
192 | local info = ChatTypeInfo["SYSTEM"]; |
||
193 | local i = 1; |
||
194 | if ( type(start) =="number" ) then i = start; end |
||
195 | if ( i < 1 ) then i =1; end |
||
196 | local text = TEXT(getglobal(pre.."_HELP_LINE"..i)); |
||
197 | while text do |
||
198 | frame:AddMessage(text, info.r, info.g, info.b, info.id); |
||
199 | i = i + 1; |
||
200 | text = TEXT(getglobal(pre.."_HELP_LINE"..i)); |
||
201 | if ( last and i > last ) then break; end |
||
202 | end |
||
203 | end |
||
204 | end -- if |
||
205 | |||
206 | -- in sec do cmd |
||
207 | SlashCmdList["SMIN"] = function(msg) |
||
208 | local _,_,s,r,c = strfind(msg, "(%d+h?%d*m?%d*s?)(%+?)%s+(.*)"); |
||
209 | if ( not c or TrimSpaces(c)=="" ) then return end |
||
210 | c=gsub(c,"\\n","\n"); |
||
211 | SuperMacro_InEnter(s,c,r); |
||
212 | end |
||
213 | |||
214 | SM_SHIFT_FORM = { bear=1,aquatic=2,cat=3,travel=4,moonkin=5, stealth=1, battle=1,defend=2,berzerk=3 }; |
||
215 | |||
216 | SlashCmdList["SMSHIFT"] = function(msg) |
||
217 | local form=msg; |
||
218 | if ( SM_SHIFT_FORM[msg] ) then |
||
219 | form=SM_SHIFT_FORM[msg]; |
||
220 | end |
||
221 | CastShapeshiftForm(form); |
||
222 | end |
||
223 | |||
224 | SlashCmdList["SMCRAFT"] = function(msg) |
||
225 | local skill, item, count = unpack(ListToTable(msg)); |
||
226 | count = tonumber(count); |
||
227 | CraftItem(skill, item, count); |
||
228 | end |
||
229 | |||
230 | SlashCmdList["SMSAYRANDOM"] = function(msg) |
||
231 | SayRandom(unpack(ListToTable(msg))); |
||
232 | end |
||
233 | |||
234 | SlashCmdList["SMCANCELBUFF"] = function(msg) |
||
235 | CancelBuff(unpack(ListToTable(msg))); |
||
236 | end |
||
237 | |||
238 | function SayRandom(...) |
||
239 | tinsert(arg, ""); |
||
240 | local r=random(arg.n); |
||
241 | RunLine(arg[r]); |
||
242 | end |
||
243 | |||
244 | function SuperMacro_InEnter( sec, cmd, rep) |
||
245 | if ( not sec or not cmd ) then return end |
||
246 | local t=SM_INFRAME.events; |
||
247 | local seconds=sec; |
||
248 | if ( strfind(seconds,'[hms]') ) then |
||
249 | seconds=gsub(seconds,'^(%d+)(h?)(%d*)(m?)(%d*)(s?)$', function(hd, h, md, m, sd, s) |
||
250 | local a=0; |
||
251 | if ( h=="h" ) then a=a+hd*3600 |
||
252 | else md=hd..md end; |
||
253 | if ( m=="m" ) then a=a+md*60 |
||
254 | else sd=md..sd end; |
||
255 | if ( sd~="" ) then a=a+sd end; |
||
256 | return a; |
||
257 | end ); |
||
258 | end |
||
259 | s=GetTime()+seconds; |
||
260 | t[s]={}; |
||
261 | t[s].cmd=cmd; |
||
262 | t[s].sec=seconds; |
||
263 | t[s].rep=rep and rep or ""; |
||
264 | t.n=t.n+1; |
||
265 | SM_INFRAME:Show(); |
||
266 | end |
||
267 | |||
268 | SM_IN=SuperMacro_InEnter; |
||
269 | |||
270 | function SM_INFRAME_OnUpdate( ) |
||
271 | local t=this.events; |
||
272 | if ( getn(t)==0 ) then |
||
273 | SM_INFRAME:Hide(); |
||
274 | end |
||
275 | for k,v in t do |
||
276 | if ( k~='n' and k<=GetTime() ) then |
||
277 | RunBody(v.cmd); |
||
278 | if ( v.rep~="" ) then |
||
279 | local s=GetTime()+v.sec; |
||
280 | t[s]={}; |
||
281 | t[s].cmd=v.cmd; |
||
282 | t[s].sec=v.sec; |
||
283 | t[s].rep=v.rep; |
||
284 | t[k]=nil; |
||
285 | else |
||
286 | t[k]=nil; |
||
287 | t.n=t.n-1; |
||
288 | end |
||
289 | end |
||
290 | end |
||
291 | end |
||
292 | |||
293 | function Pass(text) |
||
294 | if( IsCurrentAction(lastActionUsed) ) then |
||
295 | RunLine(text); |
||
296 | return text; |
||
297 | end |
||
298 | end |
||
299 | |||
300 | function Fail(text) |
||
301 | if ( not IsCurrentAction(lastActionUsed) ) then |
||
302 | RunLine(text); |
||
303 | return text; |
||
304 | end |
||
305 | end |
||
306 | |||
307 | function UseItemByName(item) |
||
308 | local bag,slot = FindItem(item); |
||
309 | if ( not bag ) then return; end; |
||
310 | if ( slot ) then |
||
311 | UseContainerItem(bag,slot); -- use, equip item in bag |
||
312 | return bag, slot; |
||
313 | else |
||
314 | UseInventoryItem(bag); -- unequip from body |
||
315 | return bag; |
||
316 | end |
||
317 | end |
||
318 | |||
319 | function use(bag, slot) |
||
320 | local b,s=tonumber(bag), tonumber(slot); |
||
321 | if ( b ) then |
||
322 | if ( s ) then |
||
323 | UseContainerItem(bag,slot); -- use, equip item in bag |
||
324 | else |
||
325 | UseInventoryItem(bag); -- unequip from body |
||
326 | end |
||
327 | else |
||
328 | UseItemByName(bag); |
||
329 | end |
||
330 | end |
||
331 | |||
332 | function DoOrder(...) |
||
333 | for k,i in arg do |
||
334 | local item=FindItem(i); |
||
335 | local spell,book=SM_FindSpell(i); |
||
336 | if ( spell and GetSpellCooldown(spell,book)==0) then |
||
337 | CastSpell(spell,book); |
||
338 | return i, spell, book; |
||
339 | end |
||
340 | if ( item and GetItemCooldown(i)==0 ) then |
||
341 | UseItemByName(i); |
||
342 | return i, item, slot; |
||
343 | end |
||
344 | end |
||
345 | end |
||
346 | |||
347 | function FindItem(item) |
||
348 | if ( not item ) then return; end |
||
349 | item = string.lower(ItemLinkToName(item)); |
||
350 | local link; |
||
351 | for i = 1,23 do |
||
352 | link = GetInventoryItemLink("player",i); |
||
353 | if ( link ) then |
||
354 | if ( item == string.lower(ItemLinkToName(link)) )then |
||
355 | return i, nil, GetInventoryItemTexture('player', i), GetInventoryItemCount('player', i); |
||
356 | end |
||
357 | end |
||
358 | end |
||
359 | local count, bag, slot, texture; |
||
360 | local totalcount = 0; |
||
361 | for i = 0,NUM_BAG_FRAMES do |
||
362 | for j = 1,MAX_CONTAINER_ITEMS do |
||
363 | link = GetContainerItemLink(i,j); |
||
364 | if ( link ) then |
||
365 | if ( item == string.lower(ItemLinkToName(link))) then |
||
366 | bag, slot = i, j; |
||
367 | texture, count = GetContainerItemInfo(i,j); |
||
368 | totalcount = totalcount + count; |
||
369 | end |
||
370 | end |
||
371 | end |
||
372 | end |
||
373 | return bag, slot, texture, totalcount; |
||
374 | end |
||
375 | |||
376 | function GetItemCooldown(item) |
||
377 | local bag, slot = FindItem(item); |
||
378 | if ( slot ) then |
||
379 | return GetContainerItemCooldown(bag, slot); |
||
380 | elseif ( bag ) then |
||
381 | return GetInventoryItemCooldown('player', bag); |
||
382 | end |
||
383 | end |
||
384 | |||
385 | function FindLastEmptyBagSlot() |
||
386 | for i=NUM_BAG_FRAMES,0,-1 do |
||
387 | for j=GetContainerNumSlots(i),1,-1 do |
||
388 | if not GetContainerItemInfo(i,j) then |
||
389 | return i,j; |
||
390 | end |
||
391 | end |
||
392 | end |
||
393 | end |
||
394 | |||
395 | function ListToTable(text) |
||
396 | local t={}; |
||
397 | -- if comma is part of item, put % before it |
||
398 | -- eg, Sulfuras%, Hand of Ragnaros |
||
399 | text=gsub(text, "%%,", "%%044"); |
||
400 | -- convert link to name, commas ok |
||
401 | text=gsub(text, "|c.-%[(.+)%]|h|r", function(x) |
||
402 | return gsub(x, ",", "%%044"); |
||
403 | end ); |
||
404 | |||
405 | gsub(text, "[^,]+", function(a) -- list separated by comma |
||
406 | a = TrimSpaces(a); |
||
407 | if ( a~="" ) then |
||
408 | a=gsub(a, "%%044", ","); |
||
409 | tinsert(t,a); |
||
410 | end |
||
411 | end); |
||
412 | return t; |
||
413 | end |
||
414 | |||
415 | function TrimSpaces(str) |
||
416 | return gsub(str,"^%s*(.-)%s*$","%1"); |
||
417 | end |
||
418 | |||
419 | function ItemLinkToName(link) |
||
420 | return gsub(link,"^.*%[(.*)%].*$","%1"); |
||
421 | end |
||
422 | |||
423 | function FindBuff( obuff, unit, item) |
||
424 | local buff=strlower(obuff); |
||
425 | local tooltip=SM_Tooltip; |
||
426 | local textleft1=getglobal(tooltip:GetName().."TextLeft1"); |
||
427 | if ( not unit ) then |
||
428 | unit ='player'; |
||
429 | end |
||
430 | local my, me, mc, oy, oe, oc = GetWeaponEnchantInfo(); |
||
431 | if ( my ) then |
||
432 | tooltip:SetOwner(UIParent, "ANCHOR_NONE"); |
||
433 | tooltip:SetInventoryItem( unit, 16); |
||
434 | for i=1, 23 do |
||
435 | local text = getglobal("SM_TooltipTextLeft"..i):GetText(); |
||
436 | if ( not text ) then |
||
437 | break; |
||
438 | elseif ( strfind(strlower(text), buff) ) then |
||
439 | tooltip:Hide(); |
||
440 | return "main",me, mc; |
||
441 | end |
||
442 | end |
||
443 | tooltip:Hide(); |
||
444 | elseif ( oy ) then |
||
445 | tooltip:SetOwner(UIParent, "ANCHOR_NONE"); |
||
446 | tooltip:SetInventoryItem( unit, 17); |
||
447 | for i=1, 23 do |
||
448 | local text = getglobal("SM_TooltipTextLeft"..i):GetText(); |
||
449 | if ( not text ) then |
||
450 | break; |
||
451 | elseif ( strfind(strlower(text), buff) ) then |
||
452 | tooltip:Hide(); |
||
453 | return "off", oe, oc; |
||
454 | end |
||
455 | end |
||
456 | tooltip:Hide(); |
||
457 | end |
||
458 | if ( item ) then return end |
||
459 | tooltip:SetOwner(UIParent, "ANCHOR_NONE"); |
||
460 | tooltip:SetTrackingSpell(); |
||
461 | local b = textleft1:GetText(); |
||
462 | if ( b and strfind(strlower(b), buff) ) then |
||
463 | tooltip:Hide(); |
||
464 | return "track",b; |
||
465 | end |
||
466 | local c=nil; |
||
467 | for i=1, 16 do |
||
468 | tooltip:SetOwner(UIParent, "ANCHOR_NONE"); |
||
469 | tooltip:SetUnitBuff(unit, i); |
||
470 | b = textleft1:GetText(); |
||
471 | tooltip:Hide(); |
||
472 | if ( b and strfind(strlower(b), buff) ) then |
||
473 | return "buff", i, b; |
||
474 | elseif ( c==b ) then |
||
475 | break; |
||
476 | end |
||
477 | --c = b; |
||
478 | end |
||
479 | c=nil; |
||
480 | for i=1, 16 do |
||
481 | tooltip:SetOwner(UIParent, "ANCHOR_NONE"); |
||
482 | tooltip:SetUnitDebuff(unit, i); |
||
483 | b = textleft1:GetText(); |
||
484 | tooltip:Hide(); |
||
485 | if ( b and strfind(strlower(b), buff) ) then |
||
486 | return "debuff", i, b; |
||
487 | elseif ( c==b) then |
||
488 | break; |
||
489 | end |
||
490 | --c = b; |
||
491 | end |
||
492 | tooltip:Hide(); |
||
493 | end |
||
494 | |||
495 | function CancelBuff(...) |
||
496 | for j=1, getn(arg) do |
||
497 | local buff = strlower(arg[j]); |
||
498 | for i=0, 24 do |
||
499 | SM_Tooltip:SetOwner(UIParent, "ANCHOR_NONE"); |
||
500 | SM_Tooltip:SetPlayerBuff(i); |
||
501 | local name = SM_TooltipTextLeft1:GetText(); |
||
502 | if ( not name ) then break end; |
||
503 | if ( strfind(strlower(name), buff) ) then |
||
504 | CancelPlayerBuff(i); |
||
505 | end |
||
506 | SM_Tooltip:Hide(); |
||
507 | end |
||
508 | end |
||
509 | end |
||
510 | |||
511 | function SM_Pickup(bag, slot) |
||
512 | if ( type(bag)=="string") then |
||
513 | if ( SM_INV_SLOT[strupper(bag)] ) then |
||
514 | bag=GetInventorySlotInfo(bag); |
||
515 | else |
||
516 | bag,slot=FindItem(bag); |
||
517 | end |
||
518 | end |
||
519 | if ( bag and not slot ) then |
||
520 | PickupInventoryItem(bag); |
||
521 | elseif ( bag and slot ) then |
||
522 | PickupContainerItem(bag, slot); |
||
523 | end |
||
524 | end |
||
525 | |||
526 | function caststop(...) |
||
527 | for i=1, arg.n do |
||
528 | CastSpellByName(arg[i]); |
||
529 | SpellStopCasting(); |
||
530 | end |
||
531 | end |
||
532 | |||
533 | function SM_Channel(spell) |
||
534 | local cf = CastingBarFrame; |
||
535 | local cd = GetSpellCooldown(SM_FindSpell(spell)); |
||
536 | if ( not cf.channeling and cd<=1.5 ) then |
||
537 | cast(spell); |
||
538 | end |
||
539 | end |
||
540 | |||
541 | function FindTradeSkillIndex(tradeskill) |
||
542 | tradeskill=strlower(tradeskill); |
||
543 | if ( TradeSkillFrame and TradeSkillFrame:IsVisible()) then |
||
544 | for i=1,GetNumTradeSkills() do |
||
545 | local tsn,tst,tsx=GetTradeSkillInfo(i); |
||
546 | if (strlower(tsn)==tradeskill) then |
||
547 | SelectTradeSkill(i); |
||
548 | TradeSkillInputBox:SetNumber(tsx); |
||
549 | TradeSkillFrame.numAvailable=tsx; |
||
550 | return i, tsx; |
||
551 | end |
||
552 | end |
||
553 | end |
||
554 | if ( CraftFrame and CraftFrame:IsVisible()) then |
||
555 | for i=1,GetNumCrafts() do |
||
556 | --craftName, craftSubSpellName, craftType, numAvailable, isExpanded,?,? |
||
557 | local tsn,_,_,tsx=GetCraftInfo(i); |
||
558 | if (strlower(tsn)==tradeskill) then |
||
559 | SelectCraft(i); |
||
560 | return i, 'c'; |
||
561 | end |
||
562 | end |
||
563 | end |
||
564 | end |
||
565 | |||
566 | function CraftItem( tradeskill, tradeitem, count) |
||
567 | if ( TradeSkillFrame and TradeSkillFrame:IsVisible() ) then |
||
568 | HideUIPanel(TradeSkillFrame); |
||
569 | end |
||
570 | if ( CraftFrame and CraftFrame:IsVisible() ) then |
||
571 | HideUIPanel(CraftFrame); |
||
572 | end |
||
573 | cast(tradeskill); |
||
574 | local index, avail = FindTradeSkillIndex(tradeitem); |
||
575 | if ( avail=='c' ) then |
||
576 | DoCraft(index); |
||
577 | elseif (avail and avail > 0) then |
||
578 | local amount; |
||
579 | count = count or 1; |
||
580 | if ( count <= 0 ) then |
||
581 | -- 0 to make all, -1 to leave 1 |
||
582 | amount =avail+count; |
||
583 | else |
||
584 | -- amount user entered |
||
585 | amount=count; |
||
586 | end |
||
587 | amount = amount<1 and 1 or amount>avail and avail or amount; |
||
588 | TradeSkillInputBox:SetNumber(amount); |
||
589 | DoTradeSkill(index, amount); |
||
590 | end |
||
591 | end |
||
592 | |||
593 | -- shortened replacements |
||
594 | -- also try Alias addon to save space, like to get player's mana |
||
595 | |||
596 | cast = CastSpellByName; |
||
597 | stopcast = SpellStopCasting; |
||
598 | echo = SM_print; |
||
599 | send = SendChatMessage; |
||
600 | buffed = FindBuff; |
||
601 | unbuff = CancelBuff; |
||
602 | pickup = SM_Pickup; |
||
603 | |||
604 | -- added debug print |
||
605 | function Printd(...) |
||
606 | for i=1, arg.n do |
||
607 | local t=arg[i] and (arg[i]~="" and arg[i] or '-""-' )or "-nil-"; |
||
608 | if ( type(t)=="boolean") then |
||
609 | t="-"..tostring(t).."-"; |
||
610 | end |
||
611 | DEFAULT_CHAT_FRAME:AddMessage(t,1,1,1); |
||
612 | end |
||
613 | end |
||
614 | |||
615 | function PrintColor(r,g,b,...) |
||
616 | for i=1, arg.n do |
||
617 | local t=arg[i] and (arg[i]~="" and arg[i] or '-""-' )or "-nil-"; |
||
618 | if ( type(t)=="boolean") then |
||
619 | t="-"..tostring(t).."-"; |
||
620 | end |
||
621 | DEFAULT_CHAT_FRAME:AddMessage(t,r,g,b); |
||
622 | end |
||
623 | end |
||
624 | |||
625 | Printc=PrintColor; |
||
626 | |||
627 | -- Prints a table in an organized format |
||
628 | function PrintTable(table, rowname, level) |
||
629 | if ( rowname == nil ) then rowname = "ROOT"; end |
||
630 | --Print(level) |
||
631 | --level = level and level or 1; |
||
632 | if ( not level ) then level = 1; end |
||
633 | local msg = ""; |
||
634 | for i=1, level do |
||
635 | msg = msg .. " "; |
||
636 | end |
||
637 | |||
638 | if ( table == nil ) then Print (msg.."["..rowname.."] := nil "); return end |
||
639 | if ( type(table) == "table" ) then |
||
640 | Print(msg..rowname.." { "); |
||
641 | for k,v in table do |
||
642 | PrintTable(v,k,level+1); |
||
643 | end |
||
644 | Print(msg.."} "); |
||
645 | elseif (type(table) == "function" ) then |
||
646 | Print(msg.."["..rowname.."] => {{FunctionPtr*}}"); |
||
647 | else |
||
648 | Print(msg.."["..rowname.."] => "..table); |
||
649 | end |
||
650 | end |
||
651 | |||
652 | Printt=PrintTable; |