Thread Tools Display Modes
10/22/16, 09:17 AM   #1
Aetheron
 
Aetheron's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 32
Mysterious nil function error

Hi All,
Combat Reticle occasionally causes an error on load - usually when loading a character for the first time, but also sometimes after fast travel (I think). The error message says:

CombatReticle_Update:3: function expected instead of nil
stack traceback:
CombatReticle_Update:3: in function '(main chunk)'

So, there is no function 'CombatReticle_Update' in my code. Where does this string come from? I'm guessing it has to do with either event registrations in the init code, or perhaps the control binding xml (<TopLevelControl name="CombatReticle" movable="false"><OnUpdate>...). Any ideas?

I do register several (4) events in the initial load function - is it possible that the game engine is calling to some of these before the are all registered? (I don't think that would cause the problem since all vars that are referenced in the handlers are already initialized)

Any help would be appreciated.

-A
  Reply With Quote
10/22/16, 09:34 AM   #2
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,913
Try to change the order in your manifest txt file so the XML file will be executed after the lua file of the addon.
Otherwise the "OnUpdate" funciton is not globally known for the XML I guess.

Code:
## APIVersion: 100016 100017
## Title: Combat Reticle
## Description: Customizable context-senstitve reticle
## Version: 1.5.1
## Author: Aetheron, updated by |c4EFFF6Calia1120|r
## OptionalDependsOn: LibAddonMenu-2.0
## SavedVariables: CombatReticle_Settings

## Libraries:
Libs/LibStub/LibStub.lua
Libs/LibAddonMenu-2.0/LibAddonMenu-2.0.lua

## Core:
CombatReticle.lua
CombatReticle.xml
CombatReticleSettings.lua
CombatReticleThemes.lua
Bindings/Bindings.xml
Bindings/Bindings.lua
  Reply With Quote
10/22/16, 09:59 AM   #3
Aetheron
 
Aetheron's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 32
Alos, I am using the LibAddonMenu which contains a lot of code - including event register/unregister stuff. Has anyone seen any issues with this on other addons?

-A
  Reply With Quote
10/22/16, 10:01 AM   #4
votan
 
votan's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 577
Originally Posted by Baertram View Post
Try to change the order in your manifest txt file so the XML file will be executed after the lua file of the addon.
Otherwise the "OnUpdate" funciton is not globally known for the XML I guess.

Code:
## APIVersion: 100016 100017
## Title: Combat Reticle
## Description: Customizable context-senstitve reticle
## Version: 1.5.1
## Author: Aetheron, updated by |c4EFFF6Calia1120|r
## OptionalDependsOn: LibAddonMenu-2.0
## SavedVariables: CombatReticle_Settings

## Libraries:
Libs/LibStub/LibStub.lua
Libs/LibAddonMenu-2.0/LibAddonMenu-2.0.lua

## Core:
CombatReticle.lua
CombatReticle.xml
CombatReticleSettings.lua
CombatReticleThemes.lua
Bindings/Bindings.xml
Bindings/Bindings.lua
Yes, I did that long time ago and do not have this error anymore.
Your TopLevelWindow is so "simple", you may want get rid of the xml and create it and register the handler in Lua.
On global function less.
  Reply With Quote
10/22/16, 10:34 AM   #5
Aetheron
 
Aetheron's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 32
I've made this change to the manifest and will test with it for a while. The error is so rare it's going to be hard to know when it's fixed. Thanks all for the help!

-A
  Reply With Quote
10/29/16, 08:41 AM   #6
Aetheron
 
Aetheron's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 32
I've just update Combat Reticle with this fix. I've been "testing" heavily for the past week and have not seen the error. So, thanks once again for the help!

-A
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » Mysterious nil function error

Thread Tools
Display Modes

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