Advertisement
suicidalkatt

QQI - QuickQuestItem

Jun 21st, 2011
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.91 KB | None | 0 0
  1. local global,character
  2. local found = nil
  3. local debug = nil
  4. local QuestItems = {}
  5.  
  6. --API
  7. --NOCOMBAT (2.0) CreateMacro("name", icon, "body", perCharacter, isLocal) - Create a new macro.
  8. --CursorHasMacro() - Returns 1 if the cursor is currently dragging a macro. (New: 2.0.3)
  9. --DeleteMacro(id or "name") - Deletes a macro.
  10. --NOCOMBAT (2.0) EditMacro(index, "name", iconIndex, "body", isLocal, perCharacter) - Saves a macro.
  11. --GetMacroBody(id or "name") - Returns the body (macro text) of a macro.
  12. --GetMacroIconInfo(index) - Returns texture of the icons provided by Blizzard.
  13. --GetMacroItemIconInfo(index) - Returns texture of the item icons provided by Blizzard
  14. --GetMacroIndexByName("name") - Returns macro index.
  15. --GetMacroInfo(id or "name") - Returns "name", "iconTexture", "body", isLocal.
  16. --GetNumMacroIcons() - Returns the number of usable icons provided by Blizzard.
  17. --GetNumMacroItemIcons() - Returns the number of usable item icons provided by Blizzard.
  18.  
  19. function QQI_UpdateMacro(unit)
  20.     global,character = GetNumMacros()
  21.     found = nil
  22.     for i=1,global do
  23.         local name = GetMacroInfo(i)
  24.         if name == "QQI_MACRO" then
  25.             found = true
  26.             if unit then
  27.                 print(unit)
  28.                 --check quest items for 'unit' update macro to use parsed item
  29.             else
  30.                 if not InCombatLockdown() end
  31.                     EditMacro(i, "QQI_MACRO",1,"#showtooltip\n--QQI_MACRO--\n/cast Mage Armor",nil,nil)
  32.                 end
  33.             end
  34.         end
  35.     end
  36.     if not found then
  37.         QQI_CreateMacro()
  38.     end
  39. end
  40.  
  41. function QQI_CreateMacro()
  42.     found = nil
  43.     global,character = GetNumMacros()
  44.     if global < 36 then -- Checks to make sure there is macro space.
  45.         for i=1,global do
  46.             local name = GetMacroInfo(i)
  47.             if name == "QQI_MACRO" then
  48.                 found = true
  49.                 QQI_UpdateMacro()
  50.                 print("Macro Updated!")
  51.             end
  52.         end
  53.         if not found and not InCombatLockdown() then
  54.             CreateMacro("QQI_MACRO",1,"--QQI_MACRO--",nil,nil)
  55.             print("Macro Created!")
  56.         end
  57.     else
  58.         print("No macro space.")
  59.     end
  60. end
  61.  
  62.  
  63. local QQI = CreateFrame("Frame","QQI")
  64. QQI:SetScript("OnEvent",function(self,event,...)
  65.     local arg1,arg2,arg3,arg4 = ...
  66.     if event == "ADDON_LOADED" then
  67.         self:UnregisterEvent("ADDON_LOADED")
  68.     elseif event == "PLAYER_ENTERING_WORLD" then
  69.         QQI_CreateMacro()
  70.     elseif event == "PLAYER_TARGET_CHANGED" then
  71.         QQI_UpdateMacro("target")
  72.     elseif event == "UPDATE_MOUSEOVER_UNIT" then
  73.         QQI_UpdateMacro("mouseover")
  74.     --elseif event == "Quest event name here" then
  75.         --ParseInventoryForQuestItems()
  76.     else
  77.         if debug then
  78.             if arg2 then
  79.                 print(event.." "..arg1.." "..arg2)
  80.             elseif arg1 then
  81.                 print(event.." "..arg1)
  82.             else
  83.                 print(event)
  84.             end
  85.         end
  86.     end
  87. end)
  88.  
  89. QQI:RegisterEvent("ADDON_LOADED")
  90. QQI:RegisterEvent("PLAYER_FOCUS_CHANGED")
  91. QQI:RegisterEvent("PLAYER_TARGET_CHANGED")
  92. QQI:RegisterEvent("PLAYER_ENTERING_WORLD")
  93. QQI:RegisterEvent("UPDATE_MOUSEOVER_UNIT")
  94. -- Register quest update events to check for any new quest items with 'use' abilities
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement