Thread Tools Display Modes
06/23/18, 11:23 AM   #1
Necrotic
Join Date: Jun 2018
Posts: 5
Function to wait till collectible is ready to use?

I am trying to make an auto helm show and hide based on combat.
When I enter or exit combat, if I'm still using a skill or attack, I get an message saying "This collectible is not ready"

UseCollectible(#) works instantly.

I wonder if there is a function that can be called that would queue up or something so when it does become available, the collectible is then used.
  Reply With Quote
06/23/18, 01:20 PM   #2
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,903
Not sure if the function here returns if the collectibel is usable at all or currentoly usable but maybe give it a try:
IsCollectibleUsable(collectibleId)

If the collectible is curently usable you can use UseCollectibel() to equip it, or else not and do it later as the fight ends maybe.
  Reply With Quote
06/24/18, 05:23 AM   #3
Necrotic
Join Date: Jun 2018
Posts: 5
Thanks but after some testing it looks like IsCollectibleUsable(collectibleId) is to see if you have the collectible unlocked or not.

I get true and at the same time I also get "This collectible is not ready" msg at the same time.
  Reply With Quote
06/24/18, 06:51 AM   #4
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,903
Ok, I thought so
Guess you don't have any function to check it then.
  Reply With Quote
06/24/18, 08:22 AM   #5
votan
 
votan's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 577
And this one: GetCollectibleCooldownAndDuration(collectibleId) ?
  Reply With Quote
06/24/18, 09:10 AM   #6
Dolgubon
 
Dolgubon's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2016
Posts: 408
As far as queueing up goes, the base game API doesn't do it very much. You'd need to register an event with the EVENT_MANAGER, probably something like EVENT_COMBAT_STATE_CHANGED. You might need to do a few other stuff like check the mounted state of the character
  Reply With Quote
06/24/18, 02:32 PM   #7
ArtOfShred
 
ArtOfShred's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2016
Posts: 103
You could just do:

Code:
function RetryFunction()
if not IsCollectibleActive(#) then
     UseCollectible(#)
else
     EVENT_MANAGER:UnregisterForUpdate("Refire")
end

function DoThat****MyDude()
     UseCollectible(#)
     EVENT_MANAGER:RegisterForUpdate("Refire", RetryFunction, 100)
end
Function will just keep trying every 100 ms until it gets used. Might want to put a counter variable on it too so it times out after a few seconds if not.

Last edited by ArtOfShred : 06/24/18 at 02:41 PM.
  Reply With Quote
06/25/18, 05:10 AM   #8
Necrotic
Join Date: Jun 2018
Posts: 5
Originally Posted by votan View Post
And this one: GetCollectibleCooldownAndDuration(collectibleId) ?
Thanks. I'll test it out. I wonder if it goes in to cool down when you enter combat with some skills.


Originally Posted by Dolgubon View Post
As far as queueing up goes, the base game API doesn't do it very much. You'd need to register an event with the EVENT_MANAGER, probably something like EVENT_COMBAT_STATE_CHANGED. You might need to do a few other stuff like check the mounted state of the character
Combat state changed is what i'm using to add or remove the helm lol. But if you use some skills.. like shield charge.. to initiate combat, it's as though the collectible had been used and is on cool down and get the warning "That collectible is not ready"


Originally Posted by ArtOfShred View Post
You could just do:

Code:
function RetryFunction()
if not IsCollectibleActive(#) then
     UseCollectible(#)
else
     EVENT_MANAGER:UnregisterForUpdate("Refire")
end

function DoThat****MyDude()
     UseCollectible(#)
     EVENT_MANAGER:RegisterForUpdate("Refire", RetryFunction, 100)
end
Function will just keep trying every 100 ms until it gets used. Might want to put a counter variable on it too so it times out after a few seconds if not.
Awesome! That is exactly what I'm looking for! Thank you so much!
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Function to wait till collectible is ready to use?

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