View Single Post
04-21-14, 03:55 PM   #26
cokedrivers
A Rage Talon Dragon Guard
 
cokedrivers's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 325
Originally Posted by Phanx View Post
OnLoad functions are called at the same time the frame is created, so the end result is the same -- the scale of the frames is never changed after the frames are created, and the frames are already created before the game starts loading any addons, so just change the scale immediately when your addon is read. You don't need to listen for any special events at all.

However, since you do need to wait for your saved variables to load, you should make sure you're not logging in in combat before attempting to do anything secure. To avoid having to split up your code or add a bunch of extra checks, and since you're just tweaking, not creating new frames or anything else critical, I'd suggest just delaying the whole thing in that case, eg.

Code:
function MyAddon:OnEnable()
     if InCombatLockdown() then
           return self:RegisterEvent("PLAYER_REGEN_ENABLED", "OnEnable")
     end
Anyway, here's a revised version of your unitframes module. I did a LOT of cleanup in the individual unit sections; the default UI never changes scales or fonts after creating the frames, so there's no need to listen for events, and even if there were, you should use your module object to listen for them, instead of creating new frames for every unit.

http://pastebin.com/f1DKpNeG
Thank You for the help yet again.

For some reason im getting a error with the "for" in the arena part of the Module.UnitFunctions could this be because the arena frams are not loaded at the start of the game?

If I --[[ ]] the arena code all is good.

Here is the error:
Code:
1x BasicUI-5.4.7\Modules\Unitframes.lua:174: "for" limit must be a number
BasicUI-5.4.7\Modules\Unitframes.lua:174: in function "func"
BasicUI-5.4.7\Modules\Unitframes.lua:51: in function <BasicUI\Modules\Unitframes.lua:37>
(tail call): ?
<in C code>
<string>:"safecall Dispatcher[1]":9: in function <string>:"safecall Dispatcher[1]":5
(tail call): ?
AuctionLite-v1.8.12\Libs\AceAddon-3.0\AceAddon-3.0-12.lua:558: in function "EnableAddon"
AuctionLite-v1.8.12\Libs\AceAddon-3.0\AceAddon-3.0-12.lua:571: in function "EnableAddon"
AuctionLite-v1.8.12\Libs\AceAddon-3.0\AceAddon-3.0-12.lua:651: in function <AuctionLite\Libs\AceAddon-3.0\AceAddon-3.0.lua:636>
<in C code>
FrameXML\UIParent.lua:306: in function "UIParentLoadAddOn"
FrameXML\UIParent.lua:329: in function "CombatLog_LoadUI"
FrameXML\UIParent.lua:742: in function <FrameXML\UIParent.lua:705>

Locals:
nil
Coke

Last edited by cokedrivers : 04-21-14 at 03:57 PM.
  Reply With Quote