|
02/27/14, 04:41 AM | #1 |
Doing everything via OnUpdate?!
I'm completly baffled by seeing this:
Code:
<GuiXml> <Controls> <TopLevelControl name="AddonName"> <OnUpdate> AddonOnUpdate(self,time) </OnUpdate> </TopLevelControl> </Controls> </GuiXml> What is wrong with doing this by event handlers? Coming from the WoW API what I would do is init my basic frames and register some specific events to do stuff for me. There has to be unit specific or aura specific events right? Is that because people don't know which events to use right now? So here is what I would do.
Do not use OnUpdate for everything in your addon. This is really bad imo. Use event handlers! ESO events: http://wiki.esoui.com/Events If you need XML to initialize your addon do this: (it may be possible that this is obsolete if you register the addon loaded event) Code:
<GuiXml> <Controls> <TopLevelControl name="AddonName"> <OnInitialized> AddonOnInitialized() </OnInitialized> </TopLevelControl> </Controls> </GuiXml> http://www.esoui.com/downloads/info1...LootAddon.html What I have not wrapped my head around yet is the event registering itself. DragonLoot uses two types of event registering. One on a global event manager and the others for the addon itself which seems to part of the global namespace after init. Lua Code:
Currently I'm not sure if you have to do it exactly that way. But it may be the case. What you should be able to do aswell is unregistering of events. Like: Lua Code:
What would really help if we could access to the default ESO addons. Basically the Lua+XML files of the "EsoUI" folder that is packed in game0000.dat. It would help a ton. Actually I have access to all of those files now but I doubt that we are allowed to post them to Github for code review. Or are we? It would be such a great help for learning how to write ESO addons. Last edited by zork : 02/27/14 at 07:40 AM. |
|
02/27/14, 11:07 AM | #2 |
Far from the truth. Many addons use OnUpdate, yes. Many of those same addons also track individual events very specifically. It greatly depends upon what you're watching and what you're updating. An on-screen clock, for example, needs to update minimum once per second... which is best done in OnUpdate. The toolbar options I have available in Framework mostly update via OnUpdate to grab zone changes, currency changes, xp/vp/ap totals, etc. It does quite a bit every tic so that the data on screen is always fresh without having to peg individual updates onto 3 or 4 dozen specific events.
Still other parts of that same addon, and same feature, track data on specific events like... gaining experience and putting the number into scrolling on-screen text. The initial update to that screen text is done via normal event triggers. The scroll is facilitated via OnUpdate tics with no buffer. ... in other words each kind of event has its purpose. |
|
02/27/14, 04:30 PM | #3 | ||
Yes, of course a clock would use an OnUpdate script as there is no event fired for the time changing.
I'm going to repost most of what I wrote on the pts forum for others to read.
|
|||
02/27/14, 04:56 PM | #4 | |
1 - There are times when it's actually more efficient to use OnUpdate. For example in my WarTools addon the Cyrodiil events actually fire too fast and I need the same data regardless of the event that fires. So... I just parse OnUpdate with a 3 second buffer and it actually results in the process running less often. 2 - The Toolbar we've both used as an example I inherited. Some of which will be rewritten in the future but the updates that are occurring there are so tiny it's not very high priority. |
||
02/28/14, 01:37 AM | #5 |
Ok just to make sure I am misunderstood.
Anyone can do whatever he wants. There is no right way but your way. I was just curious because in the first addons I checked I found no event handlers. That cleared up shortly thereafter. Anyone can have their mind on how he wants to solve a computing problem. |
|
ESOUI » Developer Discussions » General Authoring Discussion » Doing everything via OnUpdate?! |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Switch to Linear Mode |
Hybrid Mode |
Switch to Threaded Mode |
|
|