Thread Tools Display Modes
08-18-13, 03:16 AM   #1
Caellian
A Frostmaul Preserver
 
Caellian's Avatar
Join Date: May 2006
Posts: 281
Code loading priority help

Ok so, i have this addon, that runs as a dependency for almost all my other addons

http://pastebin.com/jUcx1dy8

It's been serving me well for several years. The thing is, i'm in the process of redoing my entire UI, and at the same time, move all my addons into one.

That part is almost complete and works great exept for this one.

Because it was a dependency for everything else, i was guaranteed that it would be executed first but not anymore since my UI is now one big single addon.

In short, i need a way to execute this first before any other code. I've tried several different ways, but all failed, either silently (no error but no pixel adjustment) or with an error (attempt to perform arithmetic on upvalue "ScaleFix")

This isn't very clear i know and i'm sorry about that
__________________
if (sizeof(workload) > sizeof(brain_capacity)) { die('System Overload'); }
  Reply With Quote
08-18-13, 04:59 AM   #2
Choonstertwo
A Chromatic Dragonspawn
 
Choonstertwo's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2011
Posts: 194
WoW loads your AddOn files in the order they're listed in the TOC, so you should just be able to list CaelLib's file first.
  Reply With Quote
08-18-13, 05:00 AM   #3
Caellian
A Frostmaul Preserver
 
Caellian's Avatar
Join Date: May 2006
Posts: 281
Originally Posted by Choonstertwo View Post
WoW loads your AddOn files in the order they're listed in the TOC, so you should just be able to list CaelLib's file first.
Yeah no, that's not what i meant, there's only one addon, and only one file in the toc. the UI.xml listing all the files. Putting this code above first in the XML doesn't help. Wish it was that easy lol
__________________
if (sizeof(workload) > sizeof(brain_capacity)) { die('System Overload'); }
  Reply With Quote
08-18-13, 05:12 AM   #4
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
That sounds like a pretty bad way to set up your addon -- it would probably be better to break it up into discrete parts, eg. CaelUI_UnitFrames, CaelUI_ActionBars, etc. -- but regardless of that, there's no way that listing a file first doesn't make it load first. If your "lib" file isn't being loaded first, then you've listed something else before it. Double-check your TOC and XML files, and/or post your actual files.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
08-18-13, 05:21 AM   #5
Caellian
A Frostmaul Preserver
 
Caellian's Avatar
Join Date: May 2006
Posts: 281
Originally Posted by Phanx View Post
That sounds like a pretty bad way to set up your addon -- it would probably be better to break it up into discrete parts, eg. CaelUI_UnitFrames, CaelUI_ActionBars, etc. -- but regardless of that, there's no way that listing a file first doesn't make it load first. If your "lib" file isn't being loaded first, then you've listed something else before it. Double-check your TOC and XML files, and/or post your actual files.
Well, i can guarantee that it's not a TOC or xml issue.

The TOC only loads caelUI.xml

and here's the XML

http://pastebin.com/0yJRE5tV

I don't say that it doesn't load first, i only say that if it's not loaded as an external addon, it just doesn't work, either silently or with the error above.
__________________
if (sizeof(workload) > sizeof(brain_capacity)) { die('System Overload'); }
  Reply With Quote
08-18-13, 06:07 AM   #6
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Okay, so what is the actual error message?
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
08-18-13, 06:09 AM   #7
Caellian
A Frostmaul Preserver
 
Caellian's Avatar
Join Date: May 2006
Posts: 281
Originally Posted by Phanx View Post
Okay, so what is the actual error message?
Loads of "attempt to perform arithmetic on upvalue 'ScaleFix' (a nil value)"

I may be wrong, but i believe it has to do with the resolution not being available when the UI loads
__________________
if (sizeof(workload) > sizeof(brain_capacity)) { die('System Overload'); }
  Reply With Quote
08-18-13, 06:28 AM   #8
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
Code:
eventFrame.ADDON_LOADED = function(self, event, addon)
	if addon ~= "caelLib" then
		return
	end
	[...]
end
Is the addon still called that? Guessing not. :P
__________________
Grab your sword and fight the Horde!
  Reply With Quote
08-18-13, 06:29 AM   #9
Caellian
A Frostmaul Preserver
 
Caellian's Avatar
Join Date: May 2006
Posts: 281
Originally Posted by Lombra View Post
Code:
eventFrame.ADDON_LOADED = function(self, event, addon)
	if addon ~= "caelLib" then
		return
	end
	[...]
end
Is the addon still called that?
No, but that's not it either, i had it changed to "caelUI", not sure why it wasn't in the pastey.
__________________
if (sizeof(workload) > sizeof(brain_capacity)) { die('System Overload'); }
  Reply With Quote
08-18-13, 08:06 AM   #10
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
Alright, so then there's something else that's wrong with that function (check if it actually gets called), or you try to access ScaleFix before it's called. Without knowing where the error occurs it's hard to say.
__________________
Grab your sword and fight the Horde!
  Reply With Quote
08-18-13, 08:08 AM   #11
Caellian
A Frostmaul Preserver
 
Caellian's Avatar
Join Date: May 2006
Posts: 281
Originally Posted by Lombra View Post
Without knowing where the error occurs it's hard to say.
I wouldn't be asking here otherwise

Thing is, since every single of my addon depends on this one, if this one isn't working, i've got nothing on my screen or almost, not even a chat to print something lol

But my understanding is that they're trying to access ScaleFix before it has any value.
__________________
if (sizeof(workload) > sizeof(brain_capacity)) { die('System Overload'); }

Last edited by Caellian : 08-18-13 at 08:17 AM.
  Reply With Quote
08-18-13, 08:21 AM   #12
Rilgamon
Premium Member
 
Rilgamon's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 822
Delay all other functions until your core is set up Remove everything from loading process and find out when in the process your core is available and make sure that your moduls dont request data before this time.
__________________
The cataclysm broke the world ... and the pandas could not fix it!
  Reply With Quote
08-18-13, 08:43 AM   #13
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
Load the lib in the toc file, before the xml file.
  Reply With Quote
08-18-13, 09:02 AM   #14
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
Originally Posted by Caellian View Post
I wouldn't be asking here otherwise

Thing is, since every single of my addon depends on this one, if this one isn't working, i've got nothing on my screen or almost, not even a chat to print something lol

But my understanding is that they're trying to access ScaleFix before it has any value.
What I mean is, the error message should include information such as in which file and on which line the error occurs. If it doesn't, revert to the default error UI.

As for debugging, you should be able to use the message function, which spawns a simple popup, in case your chat is not loaded. Just do something like message("addon loaded").
__________________
Grab your sword and fight the Horde!
  Reply With Quote
08-18-13, 10:17 AM   #15
Caellian
A Frostmaul Preserver
 
Caellian's Avatar
Join Date: May 2006
Posts: 281
Originally Posted by p3lim View Post
Load the lib in the toc file, before the xml file.
Tried that.

edit: it gives the error in my post below this one
__________________
if (sizeof(workload) > sizeof(brain_capacity)) { die('System Overload'); }

Last edited by Caellian : 08-18-13 at 10:26 AM.
  Reply With Quote
08-18-13, 10:24 AM   #16
Caellian
A Frostmaul Preserver
 
Caellian's Avatar
Join Date: May 2006
Posts: 281
Originally Posted by Lombra View Post
What I mean is, the error message should include information such as in which file and on which line the error occurs. If it doesn't, revert to the default error UI.

As for debugging, you should be able to use the message function, which spawns a simple popup, in case your chat is not loaded. Just do something like message("addon loaded").
But that won't help, juust now for exemple, there are 279 errors. and the first one is:

Code:
Message: Interface\AddOns\caelUI\libs\caelLib.lua:84: attempt to perform arithmetic on upvalue 'ScaleFix' (a nil value)
Time: 08/18/13 18:22:54
Count: 1
Stack: Interface\AddOns\caelUI\libs\caelLib.lua:84: in function <Interface\AddOns\caelUI\libs\caelLib.lua:83>
(tail call): ?
Interface\AddOns\caelUI\media\caelMedia.lua:61: in main chunk

Locals: value = 2
(*temporary) = nil
(*temporary) = <function> defined =[C]:-1
(*temporary) = nil
(*temporary) = "attempt to perform arithmetic on upvalue 'ScaleFix' (a nil value)"
ScaleFix = nil

as in which file and on which line the error occurs.
Basically what i explained. every single file that calls for caelLib.scale
__________________
if (sizeof(workload) > sizeof(brain_capacity)) { die('System Overload'); }

Last edited by Caellian : 08-18-13 at 10:31 AM.
  Reply With Quote
08-18-13, 10:53 AM   #17
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
Oh but it will help! You have the origin of the error in the stack trace:
Code:
Interface\AddOns\caelUI\media\caelMedia.lua:61: in main chunk
If I'm not mistaken, 'main chunk' means its executed right when the file loads. ADDON_LOADED will not have fired at that point. (I think)
__________________
Grab your sword and fight the Horde!
  Reply With Quote
08-18-13, 10:55 AM   #18
Caellian
A Frostmaul Preserver
 
Caellian's Avatar
Join Date: May 2006
Posts: 281
Originally Posted by Lombra View Post
Oh but it will help! You have the origin of the error in the stack trace:
Code:
Interface\AddOns\caelUI\media\caelMedia.lua:61: in main chunk
If I'm not mistaken, 'main chunk' means its executed right when the file loads. ADDON_LOADED will not have fired at that point. (I think)
That i didn't know, but how does that help me in this specific case ?

In order for this to work, caelLib.scale has to be available "before" any other addons loads. But ScaleFix won't have a value untill the UIScale becomes available. I don't see how to get to that.
__________________
if (sizeof(workload) > sizeof(brain_capacity)) { die('System Overload'); }

Last edited by Caellian : 08-18-13 at 11:01 AM.
  Reply With Quote
08-18-13, 11:45 AM   #19
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
I don't really know what your code does. All I can say is the problem is ScaleFix is not initialized until ADDON_LOADED fires for your addon, which is some time after all the files in your addon has been loaded.

You have to make sure that either
a) you do not try to access caelLib.scale anywhere until after your addon has fully loaded (as indicated by the ADDON_LOADED event)
b) you initialize ScaleFix immediately instead of in ADDON_LOADED

Although it looks like you're using saved variables, so b) won't be an option, save for just setting a placeholder value until the real value loads, but you'd have to refresh everything that uses the variable by then anyway, and then you may just as well go with a).
__________________
Grab your sword and fight the Horde!
  Reply With Quote
08-18-13, 12:06 PM   #20
Caellian
A Frostmaul Preserver
 
Caellian's Avatar
Join Date: May 2006
Posts: 281
Originally Posted by Lombra View Post
I don't really know what your code does. All I can say is the problem is ScaleFix is not initialized until ADDON_LOADED fires for your addon, which is some time after all the files in your addon has been loaded.

You have to make sure that either
a) you do not try to access caelLib.scale anywhere until after your addon has fully loaded (as indicated by the ADDON_LOADED event)
How can i delay my entire UI to load only once ADDON_LOADED has fired, delay a block of code is fine, but an entire UI ?
__________________
if (sizeof(workload) > sizeof(brain_capacity)) { die('System Overload'); }
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Code loading priority help


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off