Add explicit combat check and Binder.debug

Amber Yust [04-22-14 - 00:02]
Add explicit combat check and Binder.debug
Filename
Binder.lua
diff --git a/Binder.lua b/Binder.lua
index 855a24d..f675cb2 100644
--- a/Binder.lua
+++ b/Binder.lua
@@ -28,6 +28,8 @@ Binder.defaults = {
     ["autoSets"] = {},
 }

+Binder.debug = {}
+
 function Binder.BuildActionTables()
     local actionHierarchy = {}
     local actionNames = {}
@@ -108,6 +110,9 @@ function Binder.RestoreBindingsFromTable()
             end
         end
     end
+    Binder.debug.bindCount = bindCount
+    Binder.debug.skippedBindCount = skippedBindCount
+    Binder.debug.maxBindingsPerAction = maxBindings
 end

 function Binder.SaveBindings(bindSetName, isSilent)
@@ -115,6 +120,7 @@ function Binder.SaveBindings(bindSetName, isSilent)
         print("Usage: /binder save <set name>")
         return
     end
+    Binder.debug.savingSet = bindSetName
     Binder.BuildBindingsTable()
     Binder.savedVariables.bindings[bindSetName] = Binder.bindings
     if not isSilent then
@@ -122,6 +128,7 @@ function Binder.SaveBindings(bindSetName, isSilent)
     end
     local character = GetUnitName("player")
     Binder.savedVariables.autoSets[character] = bindSetName
+    Binder.debug.savedSet = bindSetName
 end

 function Binder.LoadBindings(bindSetName, isSilent)
@@ -133,6 +140,11 @@ function Binder.LoadBindings(bindSetName, isSilent)
         print("Bind set '", bindSetName, "' does not exist.")
         return
     end
+    if IsUnitInCombat("player") then
+        print("Cannot load bind set - in combat. Please try again out of combat.")
+        return
+    end
+    Binder.debug.loadingSet = bindSetName
     Binder.bindings = Binder.savedVariables.bindings[bindSetName]
     Binder.RestoreBindingsFromTable()
     if not isSilent then
@@ -140,6 +152,7 @@ function Binder.LoadBindings(bindSetName, isSilent)
     end
     local character = GetUnitName("player")
     Binder.savedVariables.autoSets[character] = bindSetName
+    Binder.debug.loadedSet = bindSetName
 end

 function Binder.ListBindings()
@@ -202,7 +215,9 @@ function Binder.SaveAutomaticBindings(isSilent)
         Binder.savedVariables.autoSets[character] = setName
     end

+    Binder.debug.autoSavingSet = setName
     Binder.SaveBindings(setName, isSilent)
+    Binder.debug.autoSavedSet = setName
 end

 function Binder.LoadAutomaticBindings(isSilent)
@@ -213,7 +228,9 @@ function Binder.LoadAutomaticBindings(isSilent)
     local setName = Binder.savedVariables.autoSets[character]

     if setName ~= nil then
+        Binder.debug.autoLoadingSet = setName
         Binder.LoadBindings(setName, isSilent)
+        Binder.debug.autoLoadedSet = setName
     else
         -- If there isn't a set to load, but automatic mode is on,
         -- create a new set.