Nameplates
Quote:
(typical for nameplate addons looking for nameplates) Note: Pulled these posts from MoP beta topic as they're no longer MoP specific. - Haleth |
Quote:
|
You still need to use WorldFrame:GetChildren() to actually iterate through potential frames. Then you can check them by name.
It would be much better if we could hook into the function that creates nameplates, but we don't have access to it. |
Quote:
Lua Code:
|
Quote:
might have to poach it for a couple addons that I've had to keep disabled in beta. :p Edit: Scratch that, a while loop won't work sadly, nameplate frames are reused for one so you don't always have a nice collection of sequential frames from 1 to n. Even if we did have that, it would still need to wrap around to index 1 when it exits the while loop. It's food for thought definitely... And another function that hard crashes the client (no addons present) GetDestinationReforgeStats() (build 15882) |
Okay, p3lim, that's clever. Should be quite a bit more efficient :p
|
Quote:
Lua Code:
|
Quote:
The OnShow handler ensures that the next time the frame is reused, we can handle updating the frame again. |
Quote:
|
Quote:
Unlike most frames, the nameplates are written (or wrapped) in C, and will not reload like the rest of the UI does. Here is a way to counter this: Lua Code:
|
Wouldn't that loop run 'forever' and keep bumping index if you happen to reload in an area with no nameplates?
|
I'd still prefer to limit the while loop to run only, say, 10 times per second, rather than every new frame. Comparing two numbers (to check if enough time has elapsed) is likely far more efficient CPU-wise than looking up a frame in _G.
Btw, I pulled these posts from the MoP topic. |
Quote:
A possible solution instead of the previous would be using a combination of an event and function that only works on a login (not reload) to reset a SV containing a variable that is set on PLAYER_LOGOUT to keep counting properly. It would lead into a monstrosity though. |
Quote:
|
Perhaps we should just request on the official forums that they add a better way for addons to do this. Since it's handled outside of lua, perhaps there could be an event like NAMEPLATE_CREATED, passing the frame as a parameter.
They listened to the request for new macro conditionals. Worth a shot, or? |
Quote:
Also, frame name or id would be enough, don't think they'd go for passing the whole frame table. Remember, I am not trying to replace the current method we are using, this is just a temporary thing to work around the issues on the beta client, and perhaps find something nice while we're at it. I agree that the nameplates should be easier to do anything with, but blizzard is avoiding showing the code, most likely to counter potential bots. |
Here we go, PLAYER_LOGOUT event saving the last index to a savedvariable, two OnUpdate scripts iterating either a new index or the savedvariable, and either of them shuts down the savedvariable one.
Lua Code:
|
Also, move this to the proper MoP discussion sub-forum, as it is not related to live clients.
|
Quote:
|
In case anyone is interested. I took p3lims advise and changed my script. I'm now checking for nameplates like this:
Lua Code:
Sidenote...the index must not be increased by 1 on logout or one nameplate will not get styled. (Because the index is already increased by 1 once an index is found. Running perfectly for now: |
Did you do any CPU profiling comparing the two methods?
|
I'm interested :)
I tested build 15913 and it seems they've fixed the :GetChildren() crash, can't reproduce it in any of the situations I used for previous build (it wasn't 100% reproducible, seemed to happen reliably when many nameplates spawned - ex. training all the mobs in Stockade). Anyway, it seems the client no longer crashes with WorldFrame:GetChildren() so I reverted back to the 'traditional' way of finding plates as simpler. Will keep an eye on this thread though for sure, an alternative is good to have. |
@ballagarba
The two versions don't differ that much. Both use OnUpdate. (Even the animationgroup does). The only big difference is that in the traditional way you iterate over all WorldFrame:GetChildren() all the time. In the new version you check just one index that is either available or not. |
Quote:
|
Why are you using an animationgroup for this?
|
Because for the past few years now it's been the cool kids' way of writing a timer. The theory is since it's done in C, it's less overhead. Since we can't measure, I don't actually buy it.
|
Quote:
one of the most requested features in my experience is the ability to control the in-game "range" at which nameplates become visible (currently "hardcoded" at 40 yards, in game terms; used to be much shorter, several major revisions ago). i requested this in the Blizzard forums, long ago and far away, but never heard a peep in response. some folks want to shorten this range, so they update fewer frames. its funny, too... i never experienced this crash with :GetChildren(). i was not among the first round(s) of Beta access granted, however. seems to have been fixed by the time i received my Blizzard email. |
Quote:
|
Alright, haven't really used animationgroups before so I just found it weird to be used like this.
One thing tho, to avoid spamming the loading process, run :Play() on PLAYER_LOGIN. Lua Code:
|
Tried both methods today, though as hard as it is to try and stress-test this, I ended up with some results.
The "new" method uses 0.01 CPU/ms less than the previous method (on average), and 0.1 CPU/ms less during stress testing (20+ nameplates). This was tested with the addon Addon Profiler, and both versions were polling 5 times per second. These values are so miniscule, you can just use what ever you prefer tbh. Personally, I will use the stuff I came up with, just because :p. |
really helpful thread. thank you for sharing this. :)
since all we like efficiency, do CVars-checking will help as well? or useless thoughts? Lua Code:
|
All times are GMT -6. The time now is 02:12 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI