WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   AddOn Search/Requests (https://www.wowinterface.com/forums/forumdisplay.php?f=6)
-   -   Cast timer addon? (https://www.wowinterface.com/forums/showthread.php?t=45755)

Nallepuh 01-29-13 09:57 AM

Cast timer addon?
 
Hi, im looking for cast timer that show amount of seconds to cast the spell, im using blizzard standard casting bar and i'm looking for a addon that just add timer to the castingbar! kinda like
http://www.wowinterface.com/download...gBarTimer.html

Thanks!!:banana:

Clamsoda 01-29-13 10:33 AM

http://addon.ziuo.net/

plus

Lua Code:
  1. CastingBarFrame.timer = CastingBarFrame:CreateFontString(nil);
  2. CastingBarFrame.timer:SetFont(STANDARD_TEXT_FONT,12,"OUTLINE");
  3. CastingBarFrame.timer:SetPoint("TOP", CastingBarFrame, "BOTTOM", 0, 0);
  4. CastingBarFrame.update = .1;
  5.  
  6. hooksecurefunc("CastingBarFrame_OnUpdate", function(self, elapsed)
  7.         if not self.timer then return end
  8.         if self.update and self.update < elapsed then
  9.                 if self.casting then
  10.                         self.timer:SetText(format("%2.1f/%1.1f", max(self.maxValue - self.value, 0), self.maxValue))
  11.                 elseif self.channeling then
  12.                         self.timer:SetText(format("%.1f", max(self.value, 0)))
  13.                 else
  14.                         self.timer:SetText("")
  15.                 end
  16.                 self.update = .1
  17.         else
  18.                 self.update = self.update - elapsed
  19.         end
  20. end)

Nallepuh 01-29-13 10:35 AM

Quote:

Originally Posted by Clamsoda (Post 272536)
Lua Code:
  1. CastingBarFrame.timer = CastingBarFrame:CreateFontString(nil);
  2. CastingBarFrame.timer:SetFont(STANDARD_TEXT_FONT,12,"OUTLINE");
  3. CastingBarFrame.timer:SetPoint("TOP", CastingBarFrame, "BOTTOM", 0, 0);
  4. CastingBarFrame.update = .1;
  5.  
  6. hooksecurefunc("CastingBarFrame_OnUpdate", function(self, elapsed)
  7.         if not self.timer then return end
  8.         if self.update and self.update < elapsed then
  9.                 if self.casting then
  10.                         self.timer:SetText(format("%2.1f/%1.1f", max(self.maxValue - self.value, 0), self.maxValue))
  11.                 elseif self.channeling then
  12.                         self.timer:SetText(format("%.1f", max(self.value, 0)))
  13.                 else
  14.                         self.timer:SetText("")
  15.                 end
  16.                 self.update = .1
  17.         else
  18.                 self.update = self.update - elapsed
  19.         end
  20. end)


thank you so much!:D but i cant get it to work!:S

Clamsoda 01-29-13 10:39 AM

1 Attachment(s)
I edited my original post with a link that allows your to turn scripts into an AddOn. I created the AddOn for you, but I suggest giving the link a go first!

Nallepuh 01-29-13 11:01 AM

Quote:

Originally Posted by Clamsoda (Post 272538)
I edited my original post with a link that allows your to turn scripts into an AddOn. I created the AddOn for you, but I suggest giving the link a go first!

thanks mate, i just copy the lua code and create my addon and give me files and then put the map in addon map, for the link you said, not good at lua that you can see!:p i can't get the file you u linked me and the LUA code to me working, am i doing something wrong?:S:(

Clamsoda 01-29-13 11:16 AM

Well, there are a few possibilities:

I didn't write the code, so it could be non-functioning code. It appears that it would work though =X. My servers are down for two more hours, I can't test that yet.

The websites gives you your AddOn in a .ZIP file. Make sure you extract the folder to your WoW's AddOn folder like any other AddOn you download.

If you are sure you extracted it correctly, and it is appearing in the in-game AddOn list, then I'll test the code here in a few hours and get back to you.

Nallepuh 01-29-13 11:17 AM

Quote:

Originally Posted by Clamsoda (Post 272543)
Well, there are a few possibilities:

I didn't write the code, so it could be non-functioning code. It appears that it would work though =X. My servers are down for two more hours, I can't test that yet.

The websites gives you your AddOn in a .ZIP file. Make sure you extract the folder to your WoW's AddOn folder like any other AddOn you download.

If you are sure you extracted it correctly, and it is appearing in the in-game AddOn list, then I'll test the code here in a few hours and get back to you.

thanks, it does appear in my addon list!

Clamsoda 01-29-13 11:26 AM

You are positive you are using the default casting bar, and that no other AddOn is trying to touch it?

Also, with LUA error reporting enabled, are any errors being produced?

Edit: Soooo, I am an idiot. I named it Blizzard..., and then WoW...yeah...just...I am so stupid. Go back up a few posts and re-download, and re-install. Make sure to delete the old one, which should have ".old" affixed to it.

I just tried it and it works.

Sorry ~.~

Nallepuh 01-29-13 11:44 AM

Quote:

Originally Posted by Clamsoda (Post 272545)
You are positive you are using the default casting bar, and that no other AddOn is trying to touch it?

Also, with LUA error reporting enabled, are any errors being produced?

Edit: Soooo, I am an idiot. I named it Blizzard..., and then WoW...yeah...just...I am so stupid. Go back up a few posts and re-download, and re-install. Make sure to delete the old one, which should have ".old" affixed to it.

I just tried it and it works.

Sorry ~.~

i works, but the cast timer is under the bar itself! i took a screen shot of it!

http://imageshack.us/photo/my-images...913184055.jpg/

Clamsoda 01-29-13 11:51 AM

Yeah, I saw that, and it sucks. I'll try to redo it so the spell text is on the left, and the time is on the right.

Nallepuh 01-29-13 11:54 AM

Quote:

Originally Posted by Clamsoda (Post 272550)
Yeah, I saw that, and it sucks. I'll try to redo it so the spell text is on the left, and the time is on the right.

i most say that: I LOVE YOU! thank you so much for your time! <3:)

Clamsoda 01-29-13 12:34 PM

Here you go. Just replace the LUA in code.lua with this, or create a new AddOn with the link at the top. Enjoy.

Lua Code:
  1. CastingBarFrame.timer = CastingBarFrame:CreateFontString(nil)
  2. CastingBarFrame.timer:SetFont(STANDARD_TEXT_FONT, 12, "NONE")
  3. CastingBarFrame.timer:SetShadowColor(0, 0, 0, 1)
  4. CastingBarFrame.timer:SetShadowOffset(1, -1)
  5. CastingBarFrame.timer:SetPoint("RIGHT", CastingBarFrame, "RIGHT", -7, 2)
  6. CastingBarFrame.update = .1
  7.  
  8. hooksecurefunc("CastingBarFrame_OnUpdate", function(self, elapsed)
  9.         if not self.timer then return end
  10.         if self.update and self.update < elapsed then
  11.                 if self.casting then
  12.                         self.timer:SetText(format("%2.1f/%1.1f", max(self.maxValue - self.value, 0), self.maxValue))
  13.                 elseif self.channeling then
  14.                         self.timer:SetText(format("%.1f", max(self.value, 0)))
  15.                 else
  16.                         self.timer:SetText("")
  17.                 end
  18.                 self.update = .1
  19.         else
  20.                 self.update = self.update - elapsed
  21.         end
  22. end)

Nallepuh 01-29-13 12:47 PM

Quote:

Originally Posted by Clamsoda (Post 272552)
Here you go. Just replace the LUA in code.lua with this, or create a new AddOn with the link at the top. Enjoy.

Lua Code:
  1. CastingBarFrame.timer = CastingBarFrame:CreateFontString(nil)
  2. CastingBarFrame.timer:SetFont(STANDARD_TEXT_FONT, 12, "NONE")
  3. CastingBarFrame.timer:SetShadowColor(0, 0, 0, 1)
  4. CastingBarFrame.timer:SetShadowOffset(1, -1)
  5. CastingBarFrame.timer:SetPoint("RIGHT", CastingBarFrame, "RIGHT", -7, 2)
  6. CastingBarFrame.update = .1
  7.  
  8. hooksecurefunc("CastingBarFrame_OnUpdate", function(self, elapsed)
  9.         if not self.timer then return end
  10.         if self.update and self.update < elapsed then
  11.                 if self.casting then
  12.                         self.timer:SetText(format("%2.1f/%1.1f", max(self.maxValue - self.value, 0), self.maxValue))
  13.                 elseif self.channeling then
  14.                         self.timer:SetText(format("%.1f", max(self.value, 0)))
  15.                 else
  16.                         self.timer:SetText("")
  17.                 end
  18.                 self.update = .1
  19.         else
  20.                 self.update = self.update - elapsed
  21.         end
  22. end)

now im getting pissed, neither dosen't work, gonna try disable all my addons and see if it works then because this is just something, cant Think of anything!:P thanks anyway!

UPDATE: nope disable my addons didnt work either!:(

i can't do anything wrong?!:S

Nallepuh 01-29-13 01:17 PM

Quote:

Originally Posted by Clamsoda (Post 272545)
You are positive you are using the default casting bar, and that no other AddOn is trying to touch it?

Also, with LUA error reporting enabled, are any errors being produced?

Edit: Soooo, I am an idiot. I named it Blizzard..., and then WoW...yeah...just...I am so stupid. Go back up a few posts and re-download, and re-install. Make sure to delete the old one, which should have ".old" affixed to it.

I just tried it and it works.

Sorry ~.~

Message: Interface\AddOns\castbar timer\code.lua:3: malformed number near '1.CastingBarFrame'
Time: 01/29/13 20:16:43
Count: 1
Stack:
Locals:



omg, im so stupid, it working now, only problem is that "healing touch" spell almost overlaps with timer! THANK YOU SO MUCH FOR YOUR TIME AND EVERYTHING YOU DID!<3

Nallepuh 01-29-13 01:27 PM

timer
 
hi, just a Quick question, if i want to remove "show total" like 1.4/2.2Žand i only want 1.4 example... in the future, what do i remove/add in LUA code! thanks!

ravagernl 01-29-13 03:27 PM

Quote:

Originally Posted by Nallepuh (Post 272558)
hi, just a Quick question, if i want to remove "show total" like 1.4/2.2Žand i only want 1.4 example... in the future, what do i remove/add in LUA code! thanks!

You would change line 12 from:
lua Code:
  1. self.timer:SetText(format("%2.1f/%1.1f", max(self.maxValue - self.value, 0), self.maxValue))

to:
lua Code:
  1. self.timer:SetText(format("%.1f", max(self.maxValue - self.value, 0)))

Phanx 01-29-13 05:39 PM

I'd suggest using the SetFormattedText method instead of SetText with an additional call to format, as the former is much faster, and doesn't fill up memory with strings.

You can also speed things up by using local variables instead of table members; reading a local variable is faster than doing a table lookup.

Also, you're basically recreating GameFontHighlight, so you might as well just use the predefined font object.

Here's the revised code:

Code:

local timer = CastingBarFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
timer:SetPoint("RIGHT", CastingBarFrame, "RIGHT", -7, 2)

local update = 0.1

hooksecurefunc("CastingBarFrame_OnUpdate", function(self, elapsed)
        update = update - elapsed
        if update <= 0 then
                if self.casting then
                        timer:SetFormattedText("%.1f", max(self.maxValue - self.value, 0))
                elseif self.channeling then
                        timer:SetFormattedText("%.1f", max(self.value, 0))
                else
                        timer:SetText("")
                end
                update = 0.1
        end
end)


Nallepuh 01-30-13 06:29 AM

Quote:

Originally Posted by ravagernl (Post 272563)
You would change line 12 from:
lua Code:
  1. self.timer:SetText(format("%2.1f/%1.1f", max(self.maxValue - self.value, 0), self.maxValue))

to:
lua Code:
  1. self.timer:SetText(format("%.1f", max(self.maxValue - self.value, 0)))

Quote:

Originally Posted by Phanx (Post 272572)
I'd suggest using the SetFormattedText method instead of SetText with an additional call to format, as the former is much faster, and doesn't fill up memory with strings.

You can also speed things up by using local variables instead of table members; reading a local variable is faster than doing a table lookup.

Also, you're basically recreating GameFontHighlight, so you might as well just use the predefined font object.

Here's the revised code:

Code:

local timer = CastingBarFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
timer:SetPoint("RIGHT", CastingBarFrame, "RIGHT", -7, 2)

local update = 0.1

hooksecurefunc("CastingBarFrame_OnUpdate", function(self, elapsed)
        update = update - elapsed
        if update <= 0 then
                if self.casting then
                        timer:SetFormattedText("%.1f", max(self.maxValue - self.value, 0))
                elseif self.channeling then
                        timer:SetFormattedText("%.1f", max(self.value, 0))
                else
                        timer:SetText("")
                end
                update = 0.1
        end
end)


thank you so much!:)


All times are GMT -6. The time now is 04:07 PM.

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