View Single Post
11-11-16, 04:38 AM   #10
lightspark
A Rage Talon Dragon Guard
 
lightspark's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2012
Posts: 341
Don't use hardcoded strings like "SPACE", "INSERT", "(s%-)", use global variables instead, e.g. SHIFT_KEY_TEXT, KEY_SPACE, KEY_INSERT, cuz different languages use different names for said keys

I do something like this and it works fine...

Lua Code:
  1. local name = button:GetName()
  2. local bType = button.buttonType
  3.  
  4. if not bType then
  5.     if name and not string.match(name, "Stance") then
  6.         if string.match(name, "PetAction") then
  7.             bType = "BONUSACTIONBUTTON"
  8.         else
  9.             bType = "ACTIONBUTTON"
  10.         end
  11.     end
  12. end
  13.  
  14. local text = bType and GetBindingText(GetBindingKey(bType..button:GetID())) or ""
  15.  
  16. if text and text ~= "" then
  17.     text = string.gsub(text, SHIFT_KEY_TEXT, "S")
  18.     text = string.gsub(text, CTRL_KEY_TEXT, "C")
  19.     text = string.gsub(text, ALT_KEY_TEXT, "A")
  20.     text = string.gsub(text, KEY_BUTTON1, "LM")
  21.     text = string.gsub(text, KEY_BUTTON2, "RM")
  22.     text = string.gsub(text, KEY_BUTTON3, "MM")
  23.     text = string.gsub(text, KEY_MOUSEWHEELDOWN, "MWD")
  24.     text = string.gsub(text, KEY_MOUSEWHEELUP, "MWU")
  25.     text = string.gsub(text, KEY_SPACE, "SP")
  26.     text = string.gsub(text, "%-", "")
  27. end

P.S. high lvl necromancy
__________________

Last edited by lightspark : 11-11-16 at 04:47 AM.
  Reply With Quote