WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Binding simple keys from LUA (https://www.wowinterface.com/forums/showthread.php?t=57206)

doofus 06-17-19 04:34 AM

Binding simple keys from LUA
 
I have observed the following:

The key bindings are stored in "D:\Games\World of Warcraft\_retail_\WTF\Account\XYZ\bindings-cache.wtf"

If you reset all your key bindings to default, then this file gets deleted or is empty

If you make a simple change, eg set ' to be action bar 5, it then creates this file with
BINDINGMODE 0
bind 5 NONE
bind ' ACTIONBUTTON5

*****************************

I usually set my special/extra key bindings using the standard UI. It then creates the bindings-cache.wtf file. For example I set "shift 1" to be "bottom left action button 1" which inserts another entry to the bindings-cache.wtf file:
bind SHIFT-2 MULTIACTIONBAR1BUTTON2

I wanted to set those key bindings from my addon in LUA. I then did this:

SetBinding("SHIFT-1", "MULTIACTIONBAR1BUTTON1")

However this does not work as imagined. I have not got to the bottom of it yet. I have observed that right after a character reload it works fine, I can press Shift-1 and get the action expected. If I then go the key-bindings UI, the multiactionbar section appears empty and even if I ESC out of it, it has now "lost" my Shift-1 binding, until another /reload or login, and then the shift-1 works just fine, as long as I do not visit the key-bindings UI.

No other addons are loaded.

Could someone please help me understand this?

MunkDev 06-17-19 07:10 AM

You're not saving your bindings. On login, and when opening the keybinding UI, it loads your current binding set using LoadBindings(set), where set is:

Code:

DEFAULT_BINDINGS (0)
ACCOUNT_BINDINGS (1)
CHARACTER_BINDINGS (2)

In order to make your bindings stay in place across sessions, you have to use SaveBindings(set).
Alternatively, if you don't want to permanently store your bindings, run your code in response to the UPDATE_BINDINGS event.

doofus 06-17-19 12:22 PM

OK, currently I load my bindings during the PLAYER_LOGIN event. I will use the save function then to make sure but will still load my bindings during every PLAYER_LOGIN just to be sure.


All times are GMT -6. The time now is 03:14 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI