Thread Tools Display Modes
04/07/14, 03:22 PM   #1
skyraker
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 154
What's wrong with this?

Lua Code:
  1. function ABT.initBookTrack(code, addOnName)
  2.     if (addOnName == "BookTracker") then
  3.         SLASH_COMMANDS["/mybooks"] = ABT.showBookWindow
  4.     end
  5. end
  6.  
  7. EVENT_MANAGER:RegisterForEvent("bookTrack", EVENT_ADD_ON_LOADED , ABT.initBookTrack)

The slash command is not being added. Yes, ABT.initBookTrack is defined. Yes, BookTracker is the title of the addon in my txt file.
  Reply With Quote
04/07/14, 03:29 PM   #2
ins
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 76
Try putting it (SLASH_COMMANDS["/mybooks"] = ABT.showBookWindow) outside the function.
  Reply With Quote
04/07/14, 03:55 PM   #3
Xrystal
caritas omnia vincit
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 369
Is ABT.showBookWindow defined as a function. The slash command line tries to run a function that processes the command line for options and allows you to test for them.

The WIKI page has a section on how to make slash commands work. I added some extra stuff to it for multiple options.
  Reply With Quote
04/07/14, 05:16 PM   #4
skyraker
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 154
Originally Posted by ins View Post
Try putting it (SLASH_COMMANDS["/mybooks"] = ABT.showBookWindow) outside the function.
Originally Posted by Xrystal View Post
Is ABT.showBookWindow defined as a function. The slash command line tries to run a function that processes the command line for options and allows you to test for them.

The WIKI page has a section on how to make slash commands work. I added some extra stuff to it for multiple options.
Putting it outside functions works, but it defeats the purpose of putting it in after the addon is verified.

Yes, ABT.showBookWindow is defined.

I think it has to do with the Event call, because nothing I put in the conditional seems to work.
  Reply With Quote
04/07/14, 05:33 PM   #5
Xrystal
caritas omnia vincit
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 369
Hmm, try a regular function name rather than one inside ABT table. I always used to have problems calling functions within a table within a function call for some reason. Other than that difference your code is almost identical to my own. The only other difference is I use the first parameter in the event registration as the name of the addon but I think it only needs to be unique rather than a specific name.

Try this variation and see if it works. If it does then hopefully one of the Lua experts can explain why your way doesn't work, cos I have no idea why.

Lua Code:
  1. local function AddonLoaded(code, addOnName)
  2.     if (addOnName == "BookTracker") then
  3.         SLASH_COMMANDS["/mybooks"] = ABT.showBookWindow
  4.     end
  5. end
  6.  
  7. EVENT_MANAGER:RegisterForEvent("bookTrack", EVENT_ADD_ON_LOADED , AddonLoaded)
  Reply With Quote
04/07/14, 05:38 PM   #6
skyraker
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 154
No, sadly. Making it a function outside ABT didn't work.
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » What's wrong with 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