11-10-14, 06:16 AM | #1 |
Exp Bar issue update
Hey everyone i have a little problem with my exp bar code
It works fine but everytime it updates it creates a new frame If someone can help me fix this i would be very happy! Lua Code:
|
|
11-10-14, 08:16 AM | #2 |
Move line 10 outside and above local function UpdateExp(). That is where you are endlessly creating a new frame every time it updates.
|
|
11-10-14, 09:25 AM | #3 |
11-10-14, 10:37 AM | #4 |
The bar value won't work or the rested exp font string.
the line 71 to 81 is that doesn't work. Lua Code:
|
|
11-10-14, 10:44 AM | #5 |
While I cant answer your question I recommend you clean up first
You're still creating new functions per update. Move all definitions out of your update function. And only put stuff in there you need to update.
__________________
The cataclysm broke the world ... and the pandas could not fix it! |
|
11-10-14, 11:05 AM | #6 | |
Lua Code:
|
||
11-10-14, 11:11 AM | #7 |
Now move the actual query (Lines 1-4) into your update function.
Your values are only computed once now. You want the values queried everytime your update is triggered. And make sure they're available, too for your OnEnter-Function.
__________________
The cataclysm broke the world ... and the pandas could not fix it! Last edited by Rilgamon : 11-10-14 at 11:15 AM. |
|
11-10-14, 11:56 AM | #8 | |
Lua Code:
|
||
11-10-14, 11:57 AM | #9 |
__________________
The cataclysm broke the world ... and the pandas could not fix it! |
|
11-10-14, 12:04 PM | #10 |
11-10-14, 12:22 PM | #11 |
Works would be cleaver to set a point to the font string too haha! Through without with the rested exp bar.. Not sure what is the wrong in that.
|
|
11-10-14, 12:27 PM | #12 |
I've changed it a little so it works without your UI and both bars show up like they should.
Lua Code:
__________________
The cataclysm broke the world ... and the pandas could not fix it! |
|
11-10-14, 01:30 PM | #13 | |
|
||
11-10-14, 04:27 PM | #14 |
Just so you know, you do not need to explicitly need to check for true, false, or nil in Lua. For readability, these are the same.
Code:
-- the value is true if a == true then ... if a ~= false then ... if a ~= nil then ... if a then ... <-- use this! -- the value is false or nil if a == false then ... if a == nil then ... if a ~= true then ... if not a then ... <-- use this! |
|
11-10-14, 05:13 PM | #15 | |
|
||
11-10-14, 05:59 PM | #16 | |
|
||
11-10-14, 07:04 PM | #17 |
I should point out that checking for 1/nil does not work as per above. If you do find a 1/nil, you will have to check, but there are a few ways.
Code:
-- if value == 1 if a == 1 then ... <-- use this! if not a == nil then ... (it isn't nil, but it might not be 1 either) if a ~= nil then ... (it isn't nil, but it might not be 1 either) if a then ... <-- will NOT work! Lua will expect a == true, when a's value is actually 1 (1 =/= true, obviously) -- if value == nil if a == nil then ... if not a then ... <-- use this! if not a == 1 then ... (it isn't 1, but it might not be nil, could be "cats" or 327) if a ~= 1 then ... (it isn't 1, but it might not be nil, could be "cats" or 327) |
|
11-10-14, 08:34 PM | #18 |
That's not actually the case. Lua's if statement works with any value, not just booleans. nil and false are false-equivalent, all other values are true-equivalent. if a then will still work as expected if a is 1/nil instead of true/false.
Last edited by Choonstertwo : 11-10-14 at 08:40 PM. |
|
11-10-14, 10:40 PM | #19 |
No. A simple "if var then" check will pass if the value of var is anything other than false or nil. It doesn't matter if it's true, 9000, a string, a table, a function, etc.
__________________
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. |
|
11-10-14, 11:46 PM | #20 |
I was thinking about 1/0 when I wrote that. Oops me.
|
|
WoWInterface » Developer Discussions » Lua/XML Help » Exp Bar issue update |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|