Thread Tools Display Modes
08/04/15, 01:07 PM   #1
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,990
Need help with keybind assertion error

Hey devs,

using the addon "DoItAll with FCO ItemSaver support" I get the following error message if I:

-Open a crafting station
-Press the key to open the mail panel
-Switch to "Send mail" tab

Error message:
Code:
assertion failed
stack traceback:
	[C]: in function 'assert'
	EsoUI/Libraries/ZO_KeybindStrip/ZO_KeybindStrip.lua:174: in function 'ZO_KeybindStrip:AddKeybindButton'
	EsoUI/Libraries/ZO_KeybindStrip/ZO_KeybindStrip.lua:287: in function 'ZO_KeybindStrip:AddKeybindButtonGroup'
	user:/AddOns/DoItAll/src/AttachAll/Keybind.lua:16: in function 'MailSendSceneStateChanged'
	EsoUI/Libraries/Utility/ZO_CallbackObject.lua:104: in function 'ZO_CallbackObject:FireCallbacks'
	EsoUI/Libraries/ZO_Scene/ZO_Scene.lua:248: in function 'ZO_Scene:SetState'
	EsoUI/Libraries/ZO_Scene/ZO_SceneManager.lua:155: in function 'ZO_SceneManager:ShowScene'
	EsoUI/Libraries/ZO_Scene/ZO_SceneManager.lua:430: in function 'ZO_SceneManager:OnSceneStateChange'
	EsoUI/Ingame/Scenes/IngameSceneManager.lua:278: in function 'ZO_IngameSceneManager:OnSceneStateChange'
	EsoUI/Libraries/ZO_Scene/ZO_Scene.lua:249: in function 'ZO_Scene:SetState'

Here is the content of the file from the error message:
Lua Code:
  1. DoItAll = DoItAll or {}
  2.  
  3. local keystripDef = {
  4.   {
  5.     name = "Attach All",
  6.     keybind = "SC_BANK_ALL",
  7.     callback = function() DoItAll.AttachAll() end,
  8.     alignment = KEYBIND_STRIP_ALIGN_LEFT,
  9.   }
  10. }
  11.  
  12. --KEYBIND_STRIP
  13.  
  14. local function MailSendSceneStateChanged(oldState, newState)
  15.   if newState == SCENE_SHOWING then
  16.     KEYBIND_STRIP:AddKeybindButtonGroup(keystripDef)
  17.   elseif newState == SCENE_HIDDEN then
  18.     KEYBIND_STRIP:RemoveKeybindButtonGroup(keystripDef)
  19.   end
  20. end
  21.  
  22. MAIL_SEND_SCENE:RegisterCallback("StateChange", MailSendSceneStateChanged)

As the keybind strip tries to call the function AddKeybindButtonGroup() the assertion fails somehow.


If I directly open the mail panel and choose the send mail tab everything works just fine.
Any ideas how to get rid of that error message AND why it happens? Maybe some keybindings from the crafting station scene mix up with it?

Thanks for your help.

EDIT: Sorry, forgot the error message :-)

Last edited by Baertram : 08/04/15 at 01:28 PM.
  Reply With Quote
08/04/15, 01:29 PM   #2
votan
 
votan's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 577
May SCENE_HIDDEN is too late? (Fading)
What if SCENE_HIDING ?
  Reply With Quote
08/04/15, 01:36 PM   #3
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
There are strange things that happen when messing with the keybindStrip, one example: http://www.esoui.com/forums/showthre...t=keybindstrip

But, I can tell you the reason is because you are using the same keybind "SC_BANK_ALL" for each keybindStrip button.
If you do your steps to reproduce the error you will notice that when you open the crafting window it shows the "Extract All" keybindStrip button. when you then click on the mail icon to open the mail from there, you are not removing that keybindStrip button. It will still show "Extract All".
Then when you switch to the Send Mail tab (since your using the same descriptor for all buttons) it is trying to place the "Attach All" button using the same "SC_BANK_ALL" keybind name which causes the assert error because that keybind/button already exists.

However, I wouldn't "just" change the names of them or just try to fix it so they remove properly. I would change it to just add the new keybindStrip button you want to the games default keybindDescriptor tables for each window then you don't have to worry about adding/removing the buttons, or any errors...like this:

Just do this instead:
Lua Code:
  1. local mailKeystripDescriptorTable = MAIL_SEND.staticKeybindStripDescriptor
  2.  
  3. local newDescriptor = {
  4.     name = "Attach All",
  5.     keybind = "SC_BANK_ALL",
  6.     callback = function() DoItAll.AttachAll() end,
  7.     alignment = KEYBIND_STRIP_ALIGN_LEFT,
  8. }
  9.  
  10. table.insert(mailKeystripDescriptorTable, newDescriptor)
Thats the only code you need (for the mail send window). The game will handle everything else.

Last edited by circonian : 08/04/15 at 01:41 PM.
  Reply With Quote
08/04/15, 01:45 PM   #4
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
Oh, and for the other widows, just find the lua files related to whatever window your trying to add something to & search for "keybindStrip" you'll get several hits, look for the one that creates the keybindStripDescriptors table, example:
Lua Code:
  1. function ZO_Smithing:InitializeKeybindStripDescriptors()
  2.     self.keybindStripDescriptor =
  3.     {
  4.         alignment = KEYBIND_STRIP_ALIGN_CENTER,
  5.  
  6.         -- Clear selections
  7.         {
  8. ....
So that one (is for all smithing panels) add a descriptor to it you would use:
Lua Code:
  1. table.insert(SMITHING.keybindStripDescriptor, newDescriptor)

Last If I remember correctly I would do the keyword search for "keybindStrip" and NOT "keybindStripDescriptor" because I think some windows name that table differently and they don't always have a InitializeKeybindStripDescriptors() function... but the keybindStrip button tables all start with "keybindStrip"

Last edited by circonian : 08/04/15 at 02:06 PM.
  Reply With Quote
08/04/15, 01:54 PM   #5
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,990
Thanks a lot for the explanation and help, as always! Very much appreciated.

I'll see what keybind strips these should be when I find the time and change it for some tests.
  Reply With Quote
08/04/15, 02:04 PM   #6
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
One last thing, I looked at DoItAll, and this might come in handy for you on the crafting windows.
You can also add a visible function to the descriptor, so you could probably just add (for example) your descriptor to the SMITHING.keybindStripDescriptor table, which makes it visible on all panels, but throw a visible function in your descriptor to determine if it should be visible or not (by checking the SMITHING.mode) rather than trying to add your descriptor to only certain panels:

EDIT (added code):
Warning: Spoiler

Last edited by circonian : 08/04/15 at 02:15 PM.
  Reply With Quote
08/04/15, 02:11 PM   #7
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,990
Ah yes, I saw this in another addon source but forgot about it again.
As DoItAll is not my addon and I only changed it to support other addons, and implemented some new features, I didn't change the basics.

Question:
Are we able to use a function to dynamically set the "name" in the keystrip definition too?

Like:
Lua Code:
  1. local function getKeyStripName()
  2.  if x = y then
  3.    return "Extract All"
  4.  else
  5.    return "Refine all"
  6.  end
  7. end
  8.  
  9. local keystripDef = {
  10.     {
  11.         name = function() getKeyStripName() end,
  12.         keybind = "SC_BANK_ALL",
  13.         callback = function() DoItAll.ExtractAll() end,
  14.         alignment = KEYBIND_STRIP_ALIGN_LEFT
  15.     }
  16. }
  Reply With Quote
08/04/15, 02:15 PM   #8
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
Yes, just make sure you "return" it
name = function() return getKeyStripName() end
here is an example:
Warning: Spoiler

Last edited by circonian : 08/04/15 at 02:23 PM.
  Reply With Quote
08/04/15, 02:16 PM   #9
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,990
Great, thank you very much!
  Reply With Quote
08/04/15, 02:51 PM   #10
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,990
Lua Code:
  1. local keystripDef = {
  2.     {
  3.         name = function() return GetKeyStripName() end,
  4.         keybind = "SC_BANK_ALL",
  5.         callback = function() DoItAll.ExtractAll() end,
  6.         alignment = KEYBIND_STRIP_ALIGN_LEFT,
  7.                 visible = function() return ShouldShow() end,
  8.     }
  9. }
  10.  
  11. table.insert(SMITHING.keybindStripDescriptor, keystripDef)   --error here

This throws me an error message that in file zo_keybindstrip.lua line 186 the table index is NIL
Code:
EsoUI/Libraries/ZO_KeybindStrip/ZO_KeybindStrip.lua:186: table index is nil
stack traceback:
	EsoUI/Libraries/ZO_KeybindStrip/ZO_KeybindStrip.lua:186: in function 'ZO_KeybindStrip:AddKeybindButton'
	EsoUI/Libraries/ZO_KeybindStrip/ZO_KeybindStrip.lua:287: in function 'ZO_KeybindStrip:AddKeybindButtonGroup'
	EsoUI/Ingame/Crafting/Smithing.lua:38: in function 'callback'
	EsoUI/Libraries/Utility/ZO_CallbackObject.lua:104: in function 'ZO_CallbackObject:FireCallbacks'
	EsoUI/Libraries/ZO_Scene/ZO_Scene.lua:248: in function 'ZO_Scene:SetState'
	EsoUI/Ingame/Scenes/InteractScene.lua:61: in function 'ZO_InteractScene:SetState'
	EsoUI/Libraries/ZO_Scene/ZO_SceneManager.lua:155: in function 'ZO_SceneManager:ShowScene'
	EsoUI/Libraries/ZO_Scene/ZO_SceneManager.lua:430: in function 'ZO_SceneManager:OnSceneStateChange'
	EsoUI/Ingame/Scenes/IngameSceneManager.lua:278: in function 'ZO_IngameSceneManager:OnSceneStateChange'
	EsoUI/Libraries/ZO_Scene/ZO_Scene.lua:249: in function 'ZO_Scene:SetState'
Lua Code:
  1. self.keybinds[keybindButtonDescriptor.keybind] = button


If I just use the old way
Lua Code:
  1. KEYBIND_STRIP:AddKeybindButtonGroup(keystripDef)
it works just fine.

Only problem is:
The name of the keybind is not changing if I change the tabs at the crafting station. The name is only updated as the keybind is added.
  Reply With Quote
08/04/15, 03:23 PM   #11
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
Ah I didn't notice that in your earlier posts, it should be:
Lua Code:
  1. local keystripDef = {
  2.         name = function() return GetKeyStripName() end,
  3.         keybind = "SC_BANK_ALL",
  4.         callback = function() DoItAll.ExtractAll() end,
  5.         alignment = KEYBIND_STRIP_ALIGN_LEFT,
  6.                 visible = function() return ShouldShow() end,
  7. }

Not 2 tables:
Its only 2 tables if you are completely replacing the entire keybindStripDescriptor table. But, were not, were just adding a table to the keybindStripDescriptor table.
Lua Code:
  1. local keystripDef = {
  2.     {
  3.         name = function() return GetKeyStripName() end,
  4.         keybind = "SC_BANK_ALL",
  5.         callback = function() DoItAll.ExtractAll() end,
  6.         alignment = KEYBIND_STRIP_ALIGN_LEFT,
  7.                 visible = function() return ShouldShow() end,
  8.     }
  9. }

Originally Posted by Baertram View Post
Only problem is:
The name of the keybind is not changing if I change the tabs at the crafting station. The name is only updated as the keybind is added.
When I use Do-It-All it shows the same text for both panels "Refinement" and "Deconstruction" both show "Extract All"
Are you trying to change the way it works to show different names?

Last edited by circonian : 08/04/15 at 03:31 PM.
  Reply With Quote
08/04/15, 03:28 PM   #12
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
Either there is some other error I'm not seeing in your code or its in your GetKeyStripName()

This works & changes names as the panels are changed:
Warning: Spoiler


EDIT: Oh, it is because you changed the way you implemented it using
Lua Code:
  1. KEYBIND_STRIP:AddKeybindButtonGroup(keystripDef)

When you do it the way I mentioned as you switch panels the buttons are refreshed automatically which re-gets the proper name. Using that other method you would have to do that yourself.

Last edited by circonian : 08/04/15 at 03:35 PM.
  Reply With Quote
08/04/15, 04:07 PM   #13
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,990
Yeah, it was the double {{}} around the keybind descriptor table...
Thanks for the hint.

Now you solution with the table.insert(SMITHING.keybindStripDescriptor, keystripDef) works fine, and is changing the names automatically!
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Need help with keybind assertion error


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