(Classic) Optimizing table search for auto dismount addon
Hi,
Been working on a new version of my Classic dismount addon; mostly, because it requires two button presses to activate an ability. In this version I register an OnKeyDown event and call for Dismount(). This works perfectly well in retail (BfA), but when my friend tries it out on the Classic Beta it requires two button presses for most abilities (excluding grenades, distract, and similar abilities that works fine). The only difference between the two of us is that I am working with a latency of 40 ms, and he around 120 ms. As such, I execute the OnKeyDown event in 1 ms and he around 3 ms. Disclaimer: to try this addon out for yourself on retail you need to disable auto dismount, and use a flying mount (and be in the air). Toc file: Code:
## Interface: 80100 Code:
local dashingDismount = CreateFrame("Frame", nil, UIParent) My question is the following: how can I make the following code more efficient? If you have any input regarding the rest of the addon feel free to provide constructive criticism. Code:
dashingDismount:SetScript("OnKeyDown", function(self, key, ...) |
It appears that the majority of time spent is due to Dismount().
I would assume that there is no way to make that faster since it is latency dependent? |
Oh, boy.
Lua Code:
|
Quote:
Was really surprised to see that Lua Code:
was a thing. Although, I assume I'll get a better understanding of the API with some experience. The only thing that had to be included in your code was to allow companion, item, and macro functionality. See modified function below. Any input on that? Lua Code:
The only thing I am unsure about is how Lua Code:
works. When and how is the button state set to checked? frame:EnableKeyboard(true) seems moot. Can set it to false (or even remove it completely) and the addon will still work. In my first version I had to set the frame to inherit from UIParent, and then show the frame for EnableKeyboard to actually work. Safe to remove it, or does it actually have some hidden function? |
Quote:
Quote:
Lua Code:
Lua Code:
Quote:
Lua Code:
Casting the shapeshift form generates an event that updates the stance bar, which results in the current stance active having its button set to checked. Lua Code:
|
Quote:
Ended up exporting the Interface code and adding them to Visual Studio with the NPL/Lua language service. Works well enough, but could be better. Serves its purpose at the very least, and I can actually follow the execution path for most things. I am pleased with the dismount AddOn now, but the only downside with it is that it seems to be latency dependent (although, I haven't had an American try it on the beta yet). On retail at 40ms latency the Dismount() function seems to take about 1ms; on classic beta with 120ms latency the Dismount() function seems to take about 3ms. Which seems to cause most abilities to require two button presses, but could be due to other changes/differences between Classic and retail. The only thing I can see myself adding to this AddOn is if there is a way to make the Dismount() function execute faster. I am not entirely sure how a hooksecurefunc works, but I would assume that it would always be executing slower than the actual Dismount() function? |
All times are GMT -6. The time now is 04:36 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI