WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Save default keybinding in Keybinding UI (https://www.wowinterface.com/forums/showthread.php?t=58203)

Walkerbo 09-10-20 06:37 PM

Save default keybinding in Keybinding UI
 
Hi all

I have set up a number of keybinds in the Binding UI; 4 of these bindings have default bindings.
Whene I first login they work without an issue; however if I /reload the default bindings disappear.
If I /logout and then log back in the defaults are once again working.

The none default bindings can be set and they will always be available; they are written to the bindings-cache.wtf file.

Here is my xml.
Lua Code:
  1. <Bindings>
  2.     <Binding name="AVKRUNSHOWAARDVARKUIFUNCTION" category="Aardvark">
  3.     print("Keybinding destroy function")
  4.         AVKRUNSHOWAARDVARKUIFUNCTION()
  5.     </Binding>
  6.     <Binding name="AVKRUNRESETAARDVARKUIFUNCTION" category="Aardvark">
  7.         print("Keybinding reset aardvark UI")
  8.     </Binding>
  9.     <Binding name="AVKRUNCLEARALLLISTSFUNCTION" category="Aardvark">
  10.         print("Keybinding clear all lists")
  11.     </Binding>
  12.     <Binding name="AVKRUNDESTROYFUNCTION" category="Aardvark">
  13.         print("Keybinding destroy function")
  14.     </Binding>
  15.     <Binding name="AVKRUNADDITEMTOGLOBALLISTFUNCTION" default="ALT-F9" category="Aardvark">
  16.         print("Keybinding add to global list")
  17.         AVKRUNADDITEMTOGLOBALLISTFUNCTION()
  18.     </Binding>
  19.     <Binding name="AVKRUNADDITEMTOCHARACTERLISTFUNCTION" default="ALT-F10" category="Aardvark">
  20.         print("Keybinding add to character list")
  21.         AVKRUNADDITEMTOCHARACTERLISTFUNCTION()
  22.     </Binding>
  23.     <Binding name="AVKRUNADDITEMTOGLOBALPROTECTLISTFUNCTION" default="ALT-F11" category="Aardvark">
  24.         print("Keybinding add to global protect list")
  25.         AVKRUNADDITEMTOGLOBALPROTECTLISTFUNCTION()
  26.     </Binding>
  27.     <Binding name="AVKRUNADDITEMTOCHARACTERPROTECTLISTFUNCTION" default="ALT-F12" category="Aardvark">
  28.         print("Keybinding add to character protect list")
  29.         AVKRUNADDITEMTOCHARACTERPROTECTLISTFUNCTION()
  30.     </Binding>
  31. </Bindings>

Is there a way to have the defaults saved to the bindings-cache.wtf file as well to ensure they are not wiped on /reload?

Walkerbo 09-11-20 11:02 PM

Hi all

After playing around for a while I decided to approach this problem in a different way.

I now check to see if the keybinding is set, if not I add it.

It does not write it to the bindings-cache.wtf file; instead it sets it upon login and /reload.

Here is my function;
Lua Code:
  1. local function ensureDefaultKeybinds()
  2.     local key1, key2
  3.     key1,key2 = GetBindingKey("AVKRUNADDITEMTOGLOBALLISTFUNCTION")
  4.     if not key1 and not key2 then
  5.         SetBinding("ALT-F9","AVKRUNADDITEMTOGLOBALLISTFUNCTION")
  6.     end
  7.     key1,key2 = GetBindingKey("AVKRUNADDITEMTOCHARACTERLISTFUNCTION")
  8.     if not key1 and not key2 then
  9.         SetBinding("ALT-F10","AVKRUNADDITEMTOCHARACTERLISTFUNCTION")
  10.     end
  11.     key1,key2 = GetBindingKey("AVKRUNADDITEMTOGLOBALPROTECTLISTFUNCTION")
  12.     if not key1 and not key2 then
  13.         SetBinding("ALT-F11","AVKRUNADDITEMTOGLOBALPROTECTLISTFUNCTION")
  14.     end
  15.     key1,key2 = GetBindingKey("AVKRUNADDITEMTOCHARACTERPROTECTLISTFUNCTION")
  16.     if not key1 and not key2 then
  17.         SetBinding("ALT-F12","AVKRUNADDITEMTOCHARACTERPROTECTLISTFUNCTION")
  18.     end
  19. end

This is most likely the nasty/inefficient solution but it gets me to where I need to be.

Any advice or better solutions would be great, but if not I will just keep playing with this and report back when/if I find a better solution.

Cheers


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

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