diff SkeletonKey/ActionTemplates.lua @ 64:178d489f387c

- fix wrong attribute names being used for macros bound from a previous profile
author Nenue
date Fri, 09 Sep 2016 11:40:53 -0400
parents 2409fe9b81e1
children 556e075983a6
line wrap: on
line diff
--- a/SkeletonKey/ActionTemplates.lua	Thu Sep 08 16:52:55 2016 -0400
+++ b/SkeletonKey/ActionTemplates.lua	Fri Sep 09 11:40:53 2016 -0400
@@ -103,26 +103,10 @@
 
 --- Resolves the SecureActionButton attribute names used for the given action
 kb.RegisterAction = function(actionType, id, name)
-
   assert(atype[actionType], 'Missing actionType handler for `'..tostring(actionType)..'`')
   local target, attributeName, attributeValue  = atype[actionType](id, name)
-
   local command = target .. attributeName
-  local baseName, iterative = attributeName, 1
-  while (kb.macros[attributeName] and kb.macros[attributeName][1] ~= attributeValue) do
-    --print(' * cannot use|cFF00FF00', attributeName, '|r"'.. tostring(kb.macros[attributeName][1]) .. '"')
-    attributeName = baseName .. '_' .. iterative
-    iterative = iterative + 1
-  end
-  if attributeName ~= baseName then
-    --print(' * Creating|cFF00FF00', attributeName)
-  else
-    --print(' * Re-using|cFF00FF00', attributeName)
-  end
   kb.macros[attributeName] = {attributeValue, command}
-
-
-  --print('RegisterAction', actionType, id, '->', attributeName, attributeValue, target .. attributeName)
   return attributeName, attributeValue, command
 end
 
@@ -202,7 +186,7 @@
     for key, command in pairs(profile.bindings) do
       cprint('|cFF00FFFF'.. key .. '|r to|cFF00FF00', command, commandActions[command])
       SetBinding(key, command)
-      if kb.bindings[command] then
+      if kb.bindings[command] and not tContains(kb.bindings[command], key) then
         tinsert(kb.bindings[command], key)
       end
     end
@@ -259,7 +243,7 @@
 end
 
 kb.UpdateMacroInfo =  function()
-  for i = 1, GetNumMacros() do
+  for index = 1, GetNumMacros() do
     local name = GetMacroInfo(index)
     kb.SecureAttribute(KeyBinderMacro, "*macro_"..tostring(name), i)
   end