comparison EnchantOnScroll.lua @ 91:d2b4b378bea4 v1.0beta7

Add number of scrolls on the enchant button
author contrebasse
date Tue, 17 May 2011 18:35:06 +0200
parents cd36938d2a48
children b980c00affcd 4d376d031f8d
comparison
equal deleted inserted replaced
90:cedd0ab21580 91:d2b4b378bea4
17 end 17 end
18 18
19 -- Check that the selected recipe can be crafted, and the crafted thing is an enchant 19 -- Check that the selected recipe can be crafted, and the crafted thing is an enchant
20 local index = GetTradeSkillSelectionIndex() 20 local index = GetTradeSkillSelectionIndex()
21 if not index then 21 if not index then
22 btn:Disable() 22 btn:Hide()
23 btn:Show()
24 return 23 return
25 end 24 end
26 local _, _, numAvailable, _, serviceType = GetTradeSkillInfo(index) 25 local _, _, numAvailable, _, serviceType = GetTradeSkillInfo(index)
27 26
28 -- serviceType is localised, but nil if an item is created 27 -- serviceType is localised, but nil if an item is created
29 if not serviceType then 28 if not serviceType then
30 btn:Hide() 29 btn:Hide()
31 return 30 return
32 end 31 end
33 if numAvailable==0 or not serviceType then 32
33 -- Check that there's scrolls in the bags
34 local itemCount = GetItemCount(SCROLL_ID)
35 if not itemCount or itemCount==0 then
36 btn:Disable()
37 btn:Show()
38 btn:SetText(A.L["Enchant a scroll (0)"])
39 return
40 end
41 btn:SetText(A.L["Enchant a scroll (%d)"]:format(itemCount))
42
43 if numAvailable==0 then
34 btn:Disable() 44 btn:Disable()
35 btn:Show() 45 btn:Show()
36 return 46 return
37 end 47 end
38 48
39 -- Check that there's scrolls in the bags
40 local itemCount = GetItemCount(SCROLL_ID)
41 if not itemCount or itemCount==0 then
42 btn:Disable()
43 btn:Show()
44 return
45 end
46
47 -- It passed the tests 49 -- It passed the tests
48 btn:Enable() 50 btn:Enable()
49 btn:Show() 51 btn:Show()
50 end 52 end
51 EventsFrame:SetScript("OnEvent",CheckButtonAvailable) 53 EventsFrame:SetScript("OnEvent",CheckButtonAvailable)