comparison 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
comparison
equal deleted inserted replaced
63:2409fe9b81e1 64:178d489f387c
101 end 101 end
102 102
103 103
104 --- Resolves the SecureActionButton attribute names used for the given action 104 --- Resolves the SecureActionButton attribute names used for the given action
105 kb.RegisterAction = function(actionType, id, name) 105 kb.RegisterAction = function(actionType, id, name)
106
107 assert(atype[actionType], 'Missing actionType handler for `'..tostring(actionType)..'`') 106 assert(atype[actionType], 'Missing actionType handler for `'..tostring(actionType)..'`')
108 local target, attributeName, attributeValue = atype[actionType](id, name) 107 local target, attributeName, attributeValue = atype[actionType](id, name)
109
110 local command = target .. attributeName 108 local command = target .. attributeName
111 local baseName, iterative = attributeName, 1
112 while (kb.macros[attributeName] and kb.macros[attributeName][1] ~= attributeValue) do
113 --print(' * cannot use|cFF00FF00', attributeName, '|r"'.. tostring(kb.macros[attributeName][1]) .. '"')
114 attributeName = baseName .. '_' .. iterative
115 iterative = iterative + 1
116 end
117 if attributeName ~= baseName then
118 --print(' * Creating|cFF00FF00', attributeName)
119 else
120 --print(' * Re-using|cFF00FF00', attributeName)
121 end
122 kb.macros[attributeName] = {attributeValue, command} 109 kb.macros[attributeName] = {attributeValue, command}
123
124
125 --print('RegisterAction', actionType, id, '->', attributeName, attributeValue, target .. attributeName)
126 return attributeName, attributeValue, command 110 return attributeName, attributeValue, command
127 end 111 end
128 112
129 113
130 114
200 end 184 end
201 185
202 for key, command in pairs(profile.bindings) do 186 for key, command in pairs(profile.bindings) do
203 cprint('|cFF00FFFF'.. key .. '|r to|cFF00FF00', command, commandActions[command]) 187 cprint('|cFF00FFFF'.. key .. '|r to|cFF00FF00', command, commandActions[command])
204 SetBinding(key, command) 188 SetBinding(key, command)
205 if kb.bindings[command] then 189 if kb.bindings[command] and not tContains(kb.bindings[command], key) then
206 tinsert(kb.bindings[command], key) 190 tinsert(kb.bindings[command], key)
207 end 191 end
208 end 192 end
209 193
210 for spellName, talentInfo in pairs(profile.talents) do 194 for spellName, talentInfo in pairs(profile.talents) do
257 kb.specInfo.id = GetSpecialization() 241 kb.specInfo.id = GetSpecialization()
258 kb.specInfo.globalID, kb.specInfo.name, kb.specInfo.desc, kb.specInfo.texture = GetSpecializationInfo(kb.specInfo.id) 242 kb.specInfo.globalID, kb.specInfo.name, kb.specInfo.desc, kb.specInfo.texture = GetSpecializationInfo(kb.specInfo.id)
259 end 243 end
260 244
261 kb.UpdateMacroInfo = function() 245 kb.UpdateMacroInfo = function()
262 for i = 1, GetNumMacros() do 246 for index = 1, GetNumMacros() do
263 local name = GetMacroInfo(index) 247 local name = GetMacroInfo(index)
264 kb.SecureAttribute(KeyBinderMacro, "*macro_"..tostring(name), i) 248 kb.SecureAttribute(KeyBinderMacro, "*macro_"..tostring(name), i)
265 end 249 end
266 end 250 end
267 251