03-18-14, 12:22 PM | #1 |
powercolor and druidform
Can i use "power.colorPower = true" on a texture other than the powerbar that updates based on the druidform.
this is what I have now, it works as long as I'm in the same stance as when I reloaded. but as soon I change form the color will not change (from yellow to red and so on) Lua Code:
and I use this to set the color Lua Code:
So I was wondering if there is another code I could use that will update when I changes form *edit: also I get a errormessage when I log in, and it is gone after a /reload Last edited by saxitoxin : 03-18-14 at 12:40 PM. |
|
03-18-14, 02:05 PM | #2 |
Please post your entire code. The snippets you posted without context are not enough to see what you are actually doing, let alone tell you why it isn't working, or what you should do instead.
__________________
Retired author of too many addons. Message me if you're interested in taking over one of my addons. Don’t message me about addon bugs or programming questions. |
|
03-18-14, 03:04 PM | #3 |
This is the entire code for the powerframe of the playerframe
Lua Code:
Everything works except for the coloring of the powerdummy when I change druid form |
|
03-18-14, 06:33 PM | #4 |
That's still very much out of context. What's in your "updatePower" function? Why are you replacing the bar's OnValueChanged script instead of using oUF's native "PostUpdate" or "Override" methods? Why are you creating your own event handling frame instead of just telling oUF which event(s) to update your element(s) on? (Also, you're never actually setting an event handling script on that frame so you may as well not be creating it in the first place, and "UNIT_powerToken" is never going to give you a valid event, as the UNIT_MANA and similar events were consolidated into UNIT_POWER several expansions ago.) What is the purpose of effectively hiding the power bar and replacing it with the "powerdummy" texture if the mystery variable "powerScroll" is set? What are you expecting this whole thing to look like and/or do?
Nobody here is psychic, and we're all far too lazy to hack into your computer just to get a look at your addon. Just post your entire file or addon.
__________________
Retired author of too many addons. Message me if you're interested in taking over one of my addons. Don’t message me about addon bugs or programming questions. |
|
03-19-14, 03:00 PM | #5 |
sorry about the vague descriptions
This is the all of the written code (way not finished yet)
This is what it looks like: album Please don't look at the mess at the bottom, that is just the prototype for how I want it to look later Credit for lots of the textures and some of the code go to Zork when it comes to your questions, I did not have the knowlege that those code existed, and I have no idea how to use them, I only started learning this two months ago. Lua Code:
Sorry for only giving only a bit of code at the time |
|
03-19-14, 06:59 PM | #6 |
To answer your original question, if you want your custom texture to follow the original bar's color (which oUF automatically sets) just grab the color from the bar in your update function:
Code:
local r, g, b = power:GetStatusBarColor() power.texture:SetVertexColor(r, g, b) Code:
hp.PostUpdate = updateHealth Code:
hp:SetScript("OnValueChanged", updateHealth) The only place you need to hook a script is for the castbar, since oUF doesn't provide any OnUpdate callback. Since OnUpdate is fairly expensive, I'd suggest not hooking it at all if the "castScroll" setting isn't enabled, rather than checking for that setting in the function itself. ----- I'm still not quite sure what you're intending to do by setting the height of the power bar to 0 when you create the rotating texture, though. If you want to hide the original bar, just do that, eg. "power:Hide()". However, it looks like you're just duplicating the texture so you can rotate it. If that's the case, you don't need to create a whole new texture; just the texture object that's already on the statusbar: Code:
power.texture = power:GetStatusBarTexture() You may also need to "remove" the regular statusbar methods so oUF isn't messing with the texture when it updates the element: Code:
local doNothing = function() end power.SetMinMaxValues = doNothing power.SetValue = doNothing I'd also recommend putting all of your config variables into a table, to avoid having tons and tons of local variables, and so that later you could move them to their own file, or add in-game options and save changed between sessions, if you wanted. This would also improve code readability, because when you saw a config variable in the code, instead of just "size" you'd see "config.size" and you'd immediately know that variable was set at the top of the file in the configuration section. There's no need to explicitly check "if <boolean value> == true then" -- you can just do "if <boolean value> then". It's cleaner and (theoretically) more efficient. Avoid calling functions unless you have to. For example, in once place you were doing "floor(x / 1000) * 1000" to "round" a value to the first 2 decimal points, but you were only using the value as a multiplier for other values, so there's no need to make it "pretty" -- just use it as-is. Similarly, there's no need to declare a variable if you're only going to use the value once. Instead of "local x = y - 42" and then "SomeFunction(x)" just do "SomeFunction(y - 42)". Finally, while a variable name like "sch" or "po" may be short and (depending on taste) pretty, are you really going to remember what it is if you haven't looked at your code for a week? a month? a year? When other programmers look at your code, will they be able to figure out what the variable is without having to go find where it's defined? Space is unlimited, so use descriptive variable names like "scrollChild" or "portraitHolder" are better choices. Also, if you have two similar objects referred to as "hpbg" and "hpbgo" don't mix them together -- calling "hpbg:SetSize" followed by "hpbg:SetTexture" followed by "hpbgo:SetTexture" followed by "hbbg:SetVertedColor" is just confusing. Keep your code organized in logical blocks.
__________________
Retired author of too many addons. Message me if you're interested in taking over one of my addons. Don’t message me about addon bugs or programming questions. |
|
03-26-14, 11:49 AM | #7 | ||
Use Reincarnation... sorry
Thanks for the help Phanx. I made a in config file back when I made the folder, I just had some problems understanding it back then so I made the settings like this in the prototype.
as for the hp.PostUpdate = updateHealth I could not make it work, I tried several times with diffrent coding, but whit no luck. So I use the old code until I figure out how to use the PostUpdate and it works ----------
Because of this I think the doNothing code vil do nothing with the dummyframe, so I did not try it. ---------- Also Thanks for all the input on the rest of the code, I did most of the rest that you suggested except the "floor(x / 1000) * 1000" since it broke the function of the hp spark. If I sound rude that is because I don't have any good English knowledge. And again thanks for the help |
|||
WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » powercolor and druidform |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|