View Single Post
10-16-14, 08:49 AM   #3
gmarco
An Onyxian Warder
 
gmarco's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 362
Hi Phanx,

it is always a great pleasure to read you.

I think I am usign your code right now "to summon" the pet, the problem is that I am not able to find now the right function to dismiss it once summoned :-)

I used:

http://wowprogramming.com/docs/api/DismissCompanion

and it worked nicely in 5.4.x, but not anymore :-/


I post the entire addon so you can understand better:

Lua Code:
  1. -- you can use the addon in a macro like this:
  2. -- /gimb [btn:2] rare; [mod:alt] funny; [mod:shift] remove;
  3. -- so you use mouse:
  4. -- btn:2 to summon a category "rare" pets
  5. -- ALT+btn:1 for the "funny" ones
  6. -- SHIFT+btn:1 for dismiss the current pet (if any)
  7. -- btn:1 for the full random.
  8.  
  9. -- if categories.lua is not found
  10. MyPets_gimb = {}
  11.  
  12. -- future use
  13. GimbolinoDB = {}
  14.  
  15. local LibPetJournal = LibStub("LibPetJournal-2.0")
  16. local prgname = "|cffffd200gimbolino|r"
  17. local summon_msg = prgname .. " is summoning... "
  18.  
  19. SLASH_GIMBOLINO1 = "/gimbolino"
  20. SLASH_GIMBOLINO2 = "/gimb"
  21. SlashCmdList["GIMBOLINO"] = function(args)  
  22.  
  23.     local category=SecureCmdOptionParse(args);
  24.     local args=SecureCmdOptionParse(args);
  25.    
  26.     if args:lower() == "help" then
  27.         print(prgname .. " commands")
  28.         print("/gimb help - This help")
  29.         print("/gimb remove - Dismiss an active pets")
  30.         print("/gimb - Random summon a pet from your complete collection")
  31.         print("/gimb <category> - Random summon a pet from your custom <category> ")
  32.         return
  33.         end
  34.    
  35.     if args:lower() == "remove" then
  36.         print(prgname .. " is dismiss the active companion")
  37.         DismissCompanion("CRITTER")
  38.         return
  39.     end    
  40.  
  41.     if not category then
  42.         return
  43.     end
  44.    
  45.     category=category:lower()
  46.    
  47.     if category=="" then       
  48.         local number=random(1,LibPetJournal:NumPets())
  49.         for i,petid in LibPetJournal:IteratePetIDs() do
  50.             local _, _, _, _, _, _, _, name, _, _, _, _, _, _, _,_,_ = C_PetJournal.GetPetInfoByPetID(petid)
  51.              if (i == number) then
  52.                     C_PetJournal.SummonPetByGUID(petid)
  53.                     print (summon_msg .. name:lower())
  54.             end
  55.         end
  56.    
  57.     elseif MyPets_gimb[category] then  
  58.             local number=random(1,#MyPets_gimb[category])
  59.             local picked=MyPets_gimb[category][number]:lower()
  60.             local msg = prgname .. " error:\ngimb was trying to summon \"" .. picked .. "\" from \"" .. category .. "\" category, but this was not found in your pets list.\nPlease check this."       
  61.             for i,petid in LibPetJournal:IteratePetIDs() do
  62.                 local _, _, _, _, _, _, _, name, _, _, _, _, _, _, _,_,_ = C_PetJournal.GetPetInfoByPetID(petid)
  63.                 if name:lower() == picked then
  64.                     C_PetJournal.SummonPetByGUID(petid)
  65.                     msg = summon_msg .. name:lower()
  66.                     break
  67.                 end
  68.             end
  69.             print(msg)                 
  70.     else
  71.         print(prgname .. " unable to find category ",category)
  72.     end
  73. end



Thanks really very much for your time.
__________________
This is Unix-Land. In quiet nights, you can hear the Windows machines reboot.
  Reply With Quote