Thread Tools Display Modes
10-16-14, 12:47 AM   #1
gmarco
An Onyxian Warder
 
gmarco's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 362
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.
__________________
This is Unix-Land. In quiet nights, you can hear the Windows machines reboot.
  Reply With Quote
10-16-14, 02:26 AM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
The companion API has been deprecated for a while. You should use the actual pet journal functions.

/run C_PetJournal.SummonPetByGUID(C_PetJournal.GetSummonedPetGUID())
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
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
10-16-14, 09:16 AM   #4
Choonstertwo
A Chromatic Dragonspawn
 
Choonstertwo's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2011
Posts: 194
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).
  Reply With Quote
10-16-14, 09:23 AM   #5
gmarco
An Onyxian Warder
 
gmarco's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 362
Originally Posted by Choonstertwo View Post
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.
__________________
This is Unix-Land. In quiet nights, you can hear the Windows machines reboot.
  Reply With Quote
10-16-14, 10:38 AM   #6
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
I noticed two of the same issue right away. You are missing the word local in front of lines 10 and 13.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » DismissCompanion("CRITTER") not work anymore ?

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off