Sjd6795 8 Posted May 12, 2023 Share Posted May 12, 2023 So I haven't found a way to add a cool down timer to a lua script, certain conditions work but it seems to ignore the cooldown time left condition and continues to spam the lua script ability. Below is the lua script for casting growl, how would I go about implementing a 8 second cooldown before it tries to run the script again? for i=1,50 do local spellName, spellSubName = GetSpellBookItemName(i, BOOKTYPE_PET) if spellName and spellName == "Growl" then CastSpell(i, BOOKTYPE_PET); end end Link to comment https://wrobot.eu/forums/topic/15169-lua-script-adding-cool-down-timer/ Share on other sites More sharing options...
Zer0 148 Posted May 12, 2023 Share Posted May 12, 2023 You can check for your pet's spell cooldown like so: local start, duration, enable = GetSpellCooldown(PET_SPELL_INDEX, 'pet') return (duration - (GetTime() - start)) * 1000 This returns the spell cooldown in milliseconds. The spell is ready when it returns a value lower than 0. You'll need to replace PET_SPELL_INDEX with i in your case. Link to comment https://wrobot.eu/forums/topic/15169-lua-script-adding-cool-down-timer/#findComment-68163 Share on other sites More sharing options...
Sjd6795 8 Posted May 13, 2023 Author Share Posted May 13, 2023 2 hours ago, Zer0 said: You can check for your pet's spell cooldown like so: local start, duration, enable = GetSpellCooldown(PET_SPELL_INDEX, 'pet') return (duration - (GetTime() - start)) * 1000 This returns the spell cooldown in milliseconds. The spell is ready when it returns a value lower than 0. You'll need to replace PET_SPELL_INDEX with i in your case. How should I implement this? I tried as Lua condition made the adjustments but crash due to to many characters. Link to comment https://wrobot.eu/forums/topic/15169-lua-script-adding-cool-down-timer/#findComment-68164 Share on other sites More sharing options...
Sjd6795 8 Posted May 13, 2023 Author Share Posted May 13, 2023 I've got all this working and even added some more C sharp and Lua scripts to my fightclass but struggling with certain conditions like. Hostile Unit Near, I am trying to setup disengage to activate when units are within a smaller range of 8. But this condition also seems to trigger from my pet which is always next to the target so it's always just spamming it when it's off cooldown. Link to comment https://wrobot.eu/forums/topic/15169-lua-script-adding-cool-down-timer/#findComment-68166 Share on other sites More sharing options...
Droidz 2738 Posted May 14, 2023 Share Posted May 14, 2023 It's c# code to ignore your pet : ObjectManager.GetWoWUnitHostile().Count(u => u.Position.DistanceTo(ObjectManager.Target.Position) <= 10 && u.IsAttackable && !u.IsMyPet) >= 3 Replace 10 by the radius (distance), and 3 by the number of hostile unit near the target require. Link to comment https://wrobot.eu/forums/topic/15169-lua-script-adding-cool-down-timer/#findComment-68167 Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now