Jump to content
Sign in to follow this  
zebus

Seeking help with simple lua edit

Recommended Posts

http://addons.us.to/addon/flexbar-0

Action bar addon that has ability to effect buttons based on events, one of those events is cooldown start and finish. However, it is seeing every global cooldown as both a cooldown start and finish for the ability.. making it pretty much useless for this function.

The code reads like this,

local start = GetActionCooldown(button:GetID());
                if start ~= 0 then
                    return true

I thought changing it to > 1.5 would fix the issue but it's still doing it, so then decided I just don't know enough about lua and thought I'd ask you guys for help.

Share this post


Link to post
Share on other sites
1 hour ago, Jorn Skyseer said:

Umm... if not(start==0)then ?

Which value are you looking for? I fail to find your question. Is it the moment when a cd ends?

Basically the addon picks up on events using conditionals which the user can then use to do stuff to his action bars. I set an event to show a button when the ability on it goes on cooldown, and then hide it when it comes off cooldown. However as written it is seeing every global cooldown as the ability both entering and leaving cooldown. So if I was to cast any ability the button would appear for 1.5s then disappear if off cooldown, which is weird because I don't remember having that issue with it back in the day.

So I want it to ignore global cooldowns and only trigger when the ability is actually used and goes on cooldown. Like I said, I know nothing about lua, I might not even be looking at the right area of the code as the culprit.

Edited by zebus

Share this post


Link to post
Share on other sites
1 hour ago, sipertruk said:

local _, duration = GetActionCooldown(slot)

if duration > 1.5 then
    -- it's not the gcd

Hmm, ok, makes sense, made the following changes but for some reason it's still returning true and showing the button when gcd triggers, does it look right? Here is the entire block from the lua

FBConditions["incooldown"] = 
	function(target)
		if not target then return false end
		if type(target) ~= "table" then
			target = { target }
		end
		
		local index, value
		for index, value in pairs(target) do
			if type(value) == "number" then
				local button = FB_GetWidgets(value)
				local duration = GetActionCooldown(button:GetID());
				if duration > 1.5 then
					return true
				end
			end
		end
		return false
	end

*edit*

Ok got it fixed, for some reason > 2 worked but not 1.5 which is totally fine. Thanks for your help.

Edited by zebus

Share this post


Link to post
Share on other sites

I will say upfront that it has been literally a decade since I last played with FlexBar, which is a seriously awesome for custom button mapping, and there is a ton that I'm probably not remembering correctly.

That said, I was wondering if you've tried using the 'IsUsable' and 'NotUsable' conditions instead of 'Cooldown', or alternatively add in=400 (400 being 40 seconds that the button would be on cooldown, adjust as needed) at the end of the show command?

Edited by Gorstavich

Share this post


Link to post
Share on other sites

In your code you forgot _,

You need the second value returned by the function which is the duration, the first being the start time so your code'll  return true in a gcd.

 

local _, duration = GetActionCooldown(slot) 

         ^

 

GetActionCooldown's complete prototype is :

start, duration, enable = GetActionCooldown(slot)

 

 

Edited by sipertruk

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×