WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   DismissCompanion("CRITTER") not work anymore ? (https://www.wowinterface.com/forums/showthread.php?t=50104)

gmarco 10-16-14 12:47 AM

DismissCompanion("CRITTER") not work anymore ?
 
Hi all,

I am slowly check my simple addons to run smoothly on patch 6.0.x.

I am now curious why this function

DismissCompanion("CRITTER")

is not working anymore for me ... even if I have found in the api changes no evidence that it should be broken/removed.

Lua Code:
  1. if args:lower() == "remove" then
  2.         print(prgname .. " is dismiss the active companion")
  3.         DismissCompanion("CRITTER")
  4.         return
  5.     end

Is it broken the function or I am doing something wrong ?

Thanks very much for your help and attention.

Phanx 10-16-14 02:26 AM

The companion API has been deprecated for a while. You should use the actual pet journal functions.

/run C_PetJournal.SummonPetByGUID(C_PetJournal.GetSummonedPetGUID())

gmarco 10-16-14 08:49 AM

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.

Choonstertwo 10-16-14 09:16 AM

If you look at the default UI's /dismisspet command, you'll see that it calls SummonPetByGUID with the currently summoned pet's GUID to dismiss it (the same as Phanx's code).

gmarco 10-16-14 09:23 AM

Quote:

Originally Posted by Choonstertwo (Post 298023)
If you look at the default UI's /dismisspet command, you'll see that it calls SummonPetByGUID with the currently summoned pet's GUID to dismiss it (the same as Phanx's code).


Sorry guys, now I have understood... I am a little bit slowly :-))

Fixed and it works like a charm with the Phanx code (as usual) :-))

Thanks again at all of you.

myrroddin 10-16-14 10:38 AM

I noticed two of the same issue right away. You are missing the word local in front of lines 10 and 13.


All times are GMT -6. The time now is 07:10 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI