Thread Tools Display Modes
03/31/14, 04:26 PM   #1
skyraker
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 154
Sometimes I hate this :)

So, I'm cleaning up my add-on by shifting more code (such as registering events) to their own functions, then calling them as necessary. I shifted the code that defines my top down window and the label control for my info bar into its own function. The label control is updated every tick.

Here's my crux. The add-on works still, but I'm getting a nil function error on the call to the label in the update function. Oddly, if I dismiss the error five times, it goes away until the next reload.

So, inside function: MS.toolText = WM:CreateControl("lsGoldT",statWin,CT_LABEL)

In update function: MS.toolText:SetText(MS.globals.barString)

This worked with no errors if I defined MS.toolText outside a function.
  Reply With Quote
03/31/14, 09:28 PM   #2
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 648
Are you creating your IsGoldT control before the OnUpdate handler is set?
  Reply With Quote
03/31/14, 10:31 PM   #3
skyraker
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 154
Using OnUpdate in the xml. Should I move it out of there?
  Reply With Quote
03/31/14, 10:39 PM   #4
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 648
I don't know. Is MS.toolText being created before the OnUpdate script is defined?
  Reply With Quote
03/31/14, 11:45 PM   #5
skyraker
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 154
Yes, the function that creates it is being called in my initialization function, which is called with EVENT_ADD_ON_LOADED. Is it possible that the update handler is being called before that?

EDIT: Just for clarification, this is the current order of things in my add-on:
Initial Declarations
Initialization Function - Calls functions to register events post-add-on start, setup the initial variable values, and create the bar
EVENT_ADD_ON_LOADED is registered - calls the above mentioned Init function
Function to create toolbar - creates top level window, then creates MS.toolText
Function for registering events post load - called from init function above
Function to setup initial variables - called from init function above
Helper function for counting saved variables
Update Handler Function
...

Last edited by skyraker : 04/01/14 at 12:17 AM.
  Reply With Quote
04/01/14, 04:51 PM   #6
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 648
So your OnUpdate handler is set in the main chunk of the addon? Not during or after the EVENT_ADD_ON_LOADED event?
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Sometimes I hate this :)


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