ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   Lua/XML Help (https://www.esoui.com/forums/forumdisplay.php?f=175)
-   -   Function to wait till collectible is ready to use? (https://www.esoui.com/forums/showthread.php?t=7889)

Necrotic 06/23/18 11:23 AM

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.

Baertram 06/23/18 01:20 PM

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.

Necrotic 06/24/18 05:23 AM

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.

Baertram 06/24/18 06:51 AM

Ok, I thought so :(
Guess you don't have any function to check it then.

votan 06/24/18 08:22 AM

And this one: GetCollectibleCooldownAndDuration(collectibleId) ?

Dolgubon 06/24/18 09:10 AM

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

ArtOfShred 06/24/18 02:32 PM

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.

Necrotic 06/25/18 05:10 AM

Quote:

Originally Posted by votan (Post 35137)
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.


Quote:

Originally Posted by Dolgubon (Post 35138)
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"


Quote:

Originally Posted by ArtOfShred (Post 35141)
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!


All times are GMT -6. The time now is 07:45 AM.

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