Why do you keep re-adding the old event handler? Your second event handler is overwriting the first one... that's why the frame is "randomly" not being shown, because the event handler that shows it is never called. If you want to update the text "smoothly" you're not registering for or responding to the power events, you're just updating every frame with the OnUpdate. What I'm posting is everything you need; I'm not just posting random bits and pieces and telling you to figure out how to put them together.
":Show()" and ":Hide()" don't return any values, so testing for the value of "something:Show()" or "something:Hide()" will always give you "nil". I'm not sure what you're asking this for, since there's no such test in the code.
I'm also not sure why you replaced "self:Show()" in the OnEvent handler with "CustomPower:Show()" since in the scope of that function, "self" is "CustomPower".
if cmd and cmd == "lock" then means "if the variable 'cmd' is not nil, and its value is the string 'lock', then". Technically it's not necessary to check for a non-nil value first, since you're comparing against a string value, but it essentially adds no overhead and is a good habit to check if something exists before comparing it against something else, since not all types of values can be directly compared against nil (numbers, for example, will error if you try to compare them to a nil value).
well u guys r lazy. i've learned a lot more by making mistakes thanks to Phanx. i'm not trying to be lazy or ask him to do the addon for me. i have little or no idea what i was doing when i started all of this. i never did anything sort of like this before. i can't just read someone's code and understand what going on when i've never completed my own first addon for a basic understanding. granted there were the other things on wow wiki but none of them were related to what i wanted to do.
here read this, this and this put it all together then do something with it. 10-1 ur first response will be "well, where do i start". at least that, is how i felt reading some of that stuff on wow wiki. Other times it was the fact that i didn't know how to connect any of the stuff i did read on there.
i guess i am an idiot but at least there was one nice person to take the time to help out this idiot out. i understand there is some people that don't want to put up with something like that. which is fine but why do u have to be mean to me cux u know more then i do?
Phanx before i put in any of your stuff i'm gonna try a few things. i didn't realize i had 2 event handlers. i didn't know they would overwrite eachother. i just saw the power event table was gone so i added them in.
If i get confused or lost i'll try ur code or use it as a reference.
I didn't say that, nor was I implying that. It just seemed to me that you were just impatiently trying to get it to work without trying to understand the whys and whats.
<snip> which is fine but why do u have to be mean to me cux u know more then i do?
I wasn't trying to be mean. I was simply pointing out that, due to my perception that you weren't actively attempting to understand the reasoning behind the code, I wasn't about to jump in as Phanx had done.
it's all cool Torhal i wasn't mad. just was bothered by how u expect people to learn just by only reading stuff.
--
i got it to lock and unlock. however on first load it's locked so i /cp lock which seems not to do anything but if i do it again it's unlocked. what could be causing this? is it cux i have not deleted the saved variable or closed the game and reloaded it? granted i have /console reloadui after any change. i have tired changing the local default from false to true but that didn't work.
to achieve the whole lock/unlock thing i had to swap 103/104 with 107/108. with the way it was it would be unlocked on load then locked forever if /cp lock was done. Am i getting or am i still mixing it up?
10-1 your going to tell me that the default value is locked so on first load it's locked. so the first /cp lock tells it to lock nothing then when done again it unlocks it.
10-1 your going to tell me that the default value is locked so on first load it's locked. so the first /cp lock tells it to lock nothing then when done again it unlocks it.
No. Actually looking through the pastes, I noticed that the problem is actually something YOU changed... in the first paste I posted (http://paste.wowace.com/540/) the lock toggle works correctly: if the current value of the "lock" setting is "true", then the toggle enables the mouse and sets the value to "false". In recent pastes you changed it so that if "lock" is "true" it enables the mouse and sets the value to "true"; this is wrong. It's this way in my most recent paste, but only because I didn't notice the change you'd made. :(
...and please just try that without making any changes, and make sure you really understand what's going on before you start changing stuff. If you're not sure what something does, or how something works, or why something works the way it does, ask.
i'm sry for all the trouble Phanx, u've been a great help tho. i will use this code in case i messed up anything else. i'll also add in the unit power table again and make sure i don't add in the old event handler. i just need to keep track of what i change and want to undo. i think using notepad 2 will help with the undo/redo thing.
also in Speedometer is FRIZQT__.ttf short for Friz Quadrata TT and is that a font in the game?
Don't add the power event table. It's not needed at all. It was only needed for the old event handler, which you should delete all copies of from your hard drive and never use again. >_<
"Fonts\\FRIZQT__ttf" is the path to one of the font files included with WoW, and yes it is Friz Quadrata.
Well, the table as it was written was simply a list of all power-related events. It wouldn't help you limit which power types were shown. What exactly do you want to do?
what would be the easiest way for me to make an options menu for which power types to show? tekconfig kinda seems lost cux i can't find any help with it or where to start.
the only thing i've added in is line 27 but that was when i was messing around with text and color which didn't really go anywhere. except for making the text red.
Well, before you start working on an options menu, you should get some actual functionality working. Although you seem to be having a really hard time giving a specific description of what you want to do, my impression is that you only want to be able to show, for example, rage and energy but not mana or runic power. Is that correct?
I'll explain, keep in mind i did call it custom power.
Main Features:
- a Text display of your class' power type - rage, runic power, w/e ( we've achieved this )
- a movable frame of the display - so you can place it any where on your screen. ( we've got this done as well )
- colored text ( sorta figured out the color but i want a color picker for w/e wacky color some1 might want )
- shared media so it can barrow fonts from other addons.
- maybe scale-able font.
Additional Options:
Pet support, and maybe w/e other power types that are used at some point.
I haven't logged on a hunter to see what it's like with a pet but with that few other questions come to mind. Like vehicles or shit that happen to ur character that have power types to them. after all, all of that is considered ur pet right?
i could careless about pets or w/e else but a "what if" came to mind that some ppl might want it. if it turns into something extra then i'd rather drop it cux i don't want it myself. i can only thing of 1 place where i'd care to see it and that is Eoe's phase 3.
For colored text, I'd really suggest just using the "default" color for each power type. Those colors are defined in the global table PowerBarColor.
For scaling, you can just scale the frame, and it will automatically scale the font string. Keep in mind that WoW will only render font strings up to 32 units (points?) in height, so if your font string's "natural" size is 16, even if you scale your frame up beyond 200%, your font string will stop growing at 200%. Speedometer also has an example of this type of scaling.
Speedometer also has a simple example of LibSharedMedia support. Look through the code for all of the references to the library, and see how it uses the library if it's present, but still works without the library.
As-is, logging onto a hunter wouldn't change anything. You'd still just see your mana. Supporting pets would require creating another frame (or font string) and adding additional code to support multiple units and update the appropriate display. I don't know of any hunters who micromanage to the degree that they actually watch their pet's focus and manually use abilities, though, so I don't think it's really something you need to worry about.
Switching to show your vehicle's power when you enter a vehicle would be pretty simple, though.
I'm busy right now, but I'll post some more code later.
forget the whole pet and vehicle thing gonna keep it to only players.
i can't find PowerBarColor on wow wiki. is it called something else?
i don't exaclty understand how LibSharedMedia works to tie into the addon. i know what it does. i can see theres a lot of references to media which relates to" LibStub and LibStub:GetLibrary("LibSharedMedia-3.0", true) ". Which parts do what?
i don't exaclty understand how LibSharedMedia works to tie into the addon. i know what it does. i can see theres a lot of references to media which relates to" LibStub and LibStub:GetLibrary("LibSharedMedia-3.0", true) ". Which parts do what?
In Speedometer.lua:
Line 28:
local defaultFont = "Fonts\\FRIZQT__.ttf"
Sets the variable "defaultFont" to point to a font file. This will be used later if LibSharedMedia-3.0 is not available.
Line 29:
local media = LibStub and LibStub:GetLibrary("LibSharedMedia-3.0", true)
Check for LibStub first, then check for the library through LibStub. If it exists, "media" is a local reference to it. Otherwise, "media" remains nil.
Line 123:
self.text:SetFont([B]media and media:Fetch("font", db.font) or defaultFont[/B], 15, outlines[db.outline])
Set the font for the display text. The bolded portion means "if 'media' is not nil, use the return value from 'media:Fetch()' with the provided arguments, otherwise use the value of 'defaultFont'".
Lines 141-144:
if media then
media.RegisterCallback(self, "LibSharedMedia_Registered", "LibSharedMedia_Update")
media.RegisterCallback(self, "LibSharedMedia_SetGlobal", "LibSharedMedia_Update")
end
If "media" isn't nil (Line 29) then register callbacks with LibSharedMedia-3.0 so that we know when new media is registered with the library by other addons.
Lines 147-151:
function Speedometer:LibSharedMedia_Update(callback, type, handle)
if media and type == "font" then
self.text:SetFont(media:Fetch("font", db.font), 15, outlines[db.outline])
end
end
This function will be called when new media is registered by addons (Lines 141-144). If the media being registered of the type "font", re-set the displayed text's font in case the user had selected a font that wasn't yet registered with the library when this addon loaded.
The rest of it is configuration stuff, and until you understand what's going on in the functional parts above, it's not relevant, so no line-by-line.
thats the code for the default player portrait isn't it?
so does that mean i have to make a power bar table for the colors? then add thoses event in to the event handler? then relate the frame to the powerbarcolor?
--
Phanx
i tried changing the font stuff before and it ended bad. i could only use fonts from the this page on wow wiki. which were game fonts. that one font i only found in xml.
so i need line 29, 123, 147-144, and 147-151 to get shared media into my addon? how much of a difference would it be to require shared media? i'd assumed only 123 would change.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
":Show()" and ":Hide()" don't return any values, so testing for the value of "something:Show()" or "something:Hide()" will always give you "nil". I'm not sure what you're asking this for, since there's no such test in the code.
I'm also not sure why you replaced "self:Show()" in the OnEvent handler with "CustomPower:Show()" since in the scope of that function, "self" is "CustomPower".
if cmd and cmd == "lock" then means "if the variable 'cmd' is not nil, and its value is the string 'lock', then". Technically it's not necessary to check for a non-nil value first, since you're comparing against a string value, but it essentially adds no overhead and is a good habit to check if something exists before comparing it against something else, since not all types of values can be directly compared against nil (numbers, for example, will error if you try to compare them to a nil value).
CustomPower.toc:
CustomPower.lua:
http://paste.wowace.com/560/
Load that up without making any changes first. Then read through it and make sure you understand what's going on. Then start adding stuff.
This is exactly why I haven't attempted to help with this. Specifically, the words in bold.
Ditto.
well u guys r lazy. i've learned a lot more by making mistakes thanks to Phanx. i'm not trying to be lazy or ask him to do the addon for me. i have little or no idea what i was doing when i started all of this. i never did anything sort of like this before. i can't just read someone's code and understand what going on when i've never completed my own first addon for a basic understanding. granted there were the other things on wow wiki but none of them were related to what i wanted to do.
here read this, this and this put it all together then do something with it. 10-1 ur first response will be "well, where do i start". at least that, is how i felt reading some of that stuff on wow wiki. Other times it was the fact that i didn't know how to connect any of the stuff i did read on there.
i guess i am an idiot but at least there was one nice person to take the time to help out this idiot out. i understand there is some people that don't want to put up with something like that. which is fine but why do u have to be mean to me cux u know more then i do?
If i get confused or lost i'll try ur code or use it as a reference.
Maybe.
I didn't say that, nor was I implying that. It just seemed to me that you were just impatiently trying to get it to work without trying to understand the whys and whats.
I wasn't trying to be mean. I was simply pointing out that, due to my perception that you weren't actively attempting to understand the reasoning behind the code, I wasn't about to jump in as Phanx had done.
--
i got it to lock and unlock. however on first load it's locked so i /cp lock which seems not to do anything but if i do it again it's unlocked. what could be causing this? is it cux i have not deleted the saved variable or closed the game and reloaded it? granted i have /console reloadui after any change. i have tired changing the local default from false to true but that didn't work.
to achieve the whole lock/unlock thing i had to swap 103/104 with 107/108. with the way it was it would be unlocked on load then locked forever if /cp lock was done. Am i getting or am i still mixing it up?
10-1 your going to tell me that the default value is locked so on first load it's locked. so the first /cp lock tells it to lock nothing then when done again it unlocks it.
Some people can learn just by reading stuff. That's how I learned. :)
Since you won't just use the code I provided without making your own changes, I don't know. You'll have to post the code you're using.
No. Actually looking through the pastes, I noticed that the problem is actually something YOU changed... in the first paste I posted (http://paste.wowace.com/540/) the lock toggle works correctly: if the current value of the "lock" setting is "true", then the toggle enables the mouse and sets the value to "false". In recent pastes you changed it so that if "lock" is "true" it enables the mouse and sets the value to "true"; this is wrong. It's this way in my most recent paste, but only because I didn't notice the change you'd made. :(
See this paste for correct code:
http://paste.wowace.com/576/
...and please just try that without making any changes, and make sure you really understand what's going on before you start changing stuff. If you're not sure what something does, or how something works, or why something works the way it does, ask.
also in Speedometer is FRIZQT__.ttf short for Friz Quadrata TT and is that a font in the game?
"Fonts\\FRIZQT__ttf" is the path to one of the font files included with WoW, and yes it is Friz Quadrata.
most of the color stuff on wow wiki doesn't exist, like there is no info. is there some place else i can look for it?
heres the code as it is atm.
http://paste.wowace.com/586/
the only thing i've added in is line 27 but that was when i was messing around with text and color which didn't really go anywhere. except for making the text red.
Main Features:
- a Text display of your class' power type - rage, runic power, w/e ( we've achieved this )
- a movable frame of the display - so you can place it any where on your screen. ( we've got this done as well )
- colored text ( sorta figured out the color but i want a color picker for w/e wacky color some1 might want )
- shared media so it can barrow fonts from other addons.
- maybe scale-able font.
Additional Options:
Pet support, and maybe w/e other power types that are used at some point.
I haven't logged on a hunter to see what it's like with a pet but with that few other questions come to mind. Like vehicles or shit that happen to ur character that have power types to them. after all, all of that is considered ur pet right?
i could careless about pets or w/e else but a "what if" came to mind that some ppl might want it. if it turns into something extra then i'd rather drop it cux i don't want it myself. i can only thing of 1 place where i'd care to see it and that is Eoe's phase 3.
For scaling, you can just scale the frame, and it will automatically scale the font string. Keep in mind that WoW will only render font strings up to 32 units (points?) in height, so if your font string's "natural" size is 16, even if you scale your frame up beyond 200%, your font string will stop growing at 200%. Speedometer also has an example of this type of scaling.
Speedometer also has a simple example of LibSharedMedia support. Look through the code for all of the references to the library, and see how it uses the library if it's present, but still works without the library.
As-is, logging onto a hunter wouldn't change anything. You'd still just see your mana. Supporting pets would require creating another frame (or font string) and adding additional code to support multiple units and update the appropriate display. I don't know of any hunters who micromanage to the degree that they actually watch their pet's focus and manually use abilities, though, so I don't think it's really something you need to worry about.
Switching to show your vehicle's power when you enter a vehicle would be pretty simple, though.
I'm busy right now, but I'll post some more code later.
i can't find PowerBarColor on wow wiki. is it called something else?
i don't exaclty understand how LibSharedMedia works to tie into the addon. i know what it does. i can see theres a lot of references to media which relates to" LibStub and LibStub:GetLibrary("LibSharedMedia-3.0", true) ". Which parts do what?
http://wowcompares.com/live/FrameXML/UnitFrame.lua
In Speedometer.lua:
Line 28:
Sets the variable "defaultFont" to point to a font file. This will be used later if LibSharedMedia-3.0 is not available.
Line 29:
Check for LibStub first, then check for the library through LibStub. If it exists, "media" is a local reference to it. Otherwise, "media" remains nil.
Line 123:
Set the font for the display text. The bolded portion means "if 'media' is not nil, use the return value from 'media:Fetch()' with the provided arguments, otherwise use the value of 'defaultFont'".
Lines 141-144:
If "media" isn't nil (Line 29) then register callbacks with LibSharedMedia-3.0 so that we know when new media is registered with the library by other addons.
Lines 147-151:
This function will be called when new media is registered by addons (Lines 141-144). If the media being registered of the type "font", re-set the displayed text's font in case the user had selected a font that wasn't yet registered with the library when this addon loaded.
The rest of it is configuration stuff, and until you understand what's going on in the functional parts above, it's not relevant, so no line-by-line.
thats the code for the default player portrait isn't it?
so does that mean i have to make a power bar table for the colors? then add thoses event in to the event handler? then relate the frame to the powerbarcolor?
--
Phanx
i tried changing the font stuff before and it ended bad. i could only use fonts from the this page on wow wiki. which were game fonts. that one font i only found in xml.
so i need line 29, 123, 147-144, and 147-151 to get shared media into my addon? how much of a difference would it be to require shared media? i'd assumed only 123 would change.