Yes, of course a clock would use an OnUpdate script as there is no event fired for the time changing.
The toolbar options I have available in Framework mostly update via OnUpdate to grab zone changes, currency changes, xp/vp/ap totals, etc.
|
There are events that fire for all of these things. You don't need to use OnUpdate. This causes your code to run MUCH more than needed. In theory, one should never use OnUpdate when an event is available.
I'm going to repost most of what I wrote on the pts forum for others to read.
If an event fires more often than you need, you should "code smarter, not harder".
...
Events fire in response to things happening in the game. You have to register for each one you want to use, and call relevant code accordingly. Some events may fire often, others rarely.
OnUpdate scripts run on each OnUpdate - this means on every frame draw. So, if your framerate is 35fps, this means that your screen is being drawn 35 times per second. The higher framerate you have, the more often your OnUpdate script will run.
The OnUpdate script handler passes the control as the first arg, and the time of the update as the second arg. This is how I only bother with running my script every so often:
Lua Code:
local timelastrun = 0 control:SetHandler("OnUpdate", function(self, timerun) if (timerun - timelastrun) >= 1 then --change 1 to however long you wish your delay to be (1, 2, 0.5, 0.1, etc) timelastrun = timerun --do stuff end end)
When a frame (control) is hidden, its OnUpdate script ceases to fire. This is an easy way to start/stop your OnUpdate script.
|
Also, Wykkyd, I believe you're still calling OnUpdate scripts events. They are not.