Thread Tools Display Modes
09-18-23, 12:26 AM   #1
Blandros
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Sep 2023
Posts: 13
LUA Code GetBindingAction

Hello,
i am trying to revive an old Addon (KeyBinder). I only have little knowledge about LUA coding. But somehow I've managed it quite well so far.

But i‘ve came around the problem that only the Keys 1, 2, 3, …, 8, 9, with ACTIONBUTTON1, ACTIONBUTTON2, etc. are working.
The other keys for example Q with MULTIACTIONBAR4BUTTON11 arent working.

Lua Code:
  1. -- SetKey(button) - Determines the texture or text displayed on the button based on the key binding.
  2. function addon:SetKey(button)
  3.     local spell = GetBindingAction(modif.CTRL .. modif.SHIFT .. modif.ALT .. (button.label:GetText() or "")) or ""
  4.  
  5.     if spell:find("^SPELL") then
  6.         button.icon:Show()
  7.         spell = spell:match("SPELL%s(.*)")
  8.         button.icon:SetTexture(GetSpellTexture(spell))
  9.         button.icon:SetTexCoord(0.1, 0.9, 0.1, 0.9)
  10.         button.type = "spell"
  11.     elseif spell:find("^MACRO") then
  12.         button.icon:Show()
  13.         spell = spell:match("MACRO%s(.*)")
  14.         button.icon:SetTexture(select(2, GetMacroInfo(spell)))
  15.         button.icon:SetTexCoord(0.1, 0.9, 0.1, 0.9)
  16.         button.type = "macro"
  17.     elseif spell:find("^ITEM") then
  18.         button.icon:Show()
  19.         spell = spell:match("ITEM%s(.*)")
  20.         button.icon:SetTexture(select(10, GetItemInfo(spell)))
  21.         button.icon:SetTexCoord(0.1, 0.9, 0.1, 0.9)
  22.         button.type = "item"
  23.     else
  24.         button.icon:Hide()
  25.         local found = false
  26.         for i = 1, GetNumBindings() do
  27.             local a = GetBinding(i)
  28.             if spell:find(a) then
  29.                 local slot = spell:match("ACTIONBUTTON(%d+)") or spell:match("BT4Button(%d+)")
  30.  
  31.                 if slot then
  32.                     button.icon:SetTexture(GetActionTexture(slot))
  33.                     button.icon:SetTexCoord(0.1, 0.9, 0.1, 0.9)
  34.                     button.icon:Show()
  35.                     button.slot = slot
  36.                 end
  37.                 spell = GetBindingText(spell, "BINDING_NAME_") or spell
  38.                 button.type = "interface"
  39.                 found = true
  40.             end
  41.         end
  42.         if not found then
  43.             button.type = "none"
  44.         end
  45.     end
  46.     button.macro:SetText(spell)
  47. end

Last edited by Blandros : 09-18-23 at 06:22 AM.
  Reply With Quote
09-19-23, 12:58 AM   #2
Blandros
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Sep 2023
Posts: 13
I got it working:
https://legacy.curseforge.com/wow/addons/keyui

Last edited by Blandros : 09-19-23 at 01:00 AM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » LUA Code GetBindingAction


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